File Exchange Pick of the Week

Our best user submissions

Spelling out numbers

Jiro's pick this week is num2words by Stephen Cobeldick.

Just recently, I witnessed a typo on a check payment. The amount was for "$19050" (unfortunately, it wasn't for me) but the written text read "One thousand nine hundred fifty dollars". Many people might wonder why someone would make such a simple mistake. Did the person miscount the number of zeroes?

I think I have an idea. This was written in Japan. In Japan, and in many other Asian countries, large numbers are grouped in myriads (every 10000). is called man (万), is called oku (億), is called cho (兆). However in Western counting, large numbers are grouped in 1000s - thousand, million, billion, trillion, etc. So, it's likely that the person writing the check wrote "19050", read it as "1 man 9050", and incorrectly translated to "1 thousand 9 hundred 50". Maybe...

Anyway, all of this could have been avoided if this person had access to Stephen's num2words! Just let his function spell out the number in words.

num2words(19050)
ans =
nineteen thousand and fifty

This is the simplest use case, but num2words comes with a wealth of options to customize how the results are returned.

num2words(19050,'type','cheque')
ans =
nineteen thousand and fifty dollars only

Stephen includes a detailed help in the function, so you can learn about all the options just by typing

help num2words

What gave me a little chuckle was that when I looked inside his function, I could see that he made sure that his function can count up to Uncentillion which is . So if you need to spell out a number larger than , you might be out of luck. :)

Comments

Give this a try, and let us know what you think here or leave a comment for Stephen.




Published with MATLAB® R2014b

|
  • print

コメント

コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。