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.
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.
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
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. :)
Give this a try, and let us know what you think here or leave a comment for Stephen.
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.