We currently have a crude mechanism to convert numbers to words (e.g. using a few static arrays) and based on the size of the number translating that into an english text. But we are running into issues for numbers which are huge.
10183 = Ten thousand one hundred eighty three
90 = Ninety
5888 = Five thousand eight hundred eighty eight
Is there an easy to use function in any of the math libraries which I can use for this purpose?
Just uploaded an extensible version! NumberReader @ SourceForge
I've developed a Java component to convert given number into words. All you've to do is - just copy the whole class from
Java program to convert numbers to wordsand paste it in your project.Just invoke it like below
My program supports up to 10 million. If you want, you can still extend this. Just below the example output
Thanks
Santhosh
I have used 2 dimensional array...
}
Take a look at Tradukisto. It's a Java library I've written which does the job.
ICU4J contains nice number-spellout support. The files with the "rules" can be easily edited, and it's no problem to add other languages (we did it e.g. for Polish and Russian).
In this post i have just update Yanick Rochon's code. I have make it workable with lower version of java 1.6 and i was getting the output for 1.00 = one and hundredth. So i have update the code. New i get the output for 1.00 = one and zero hundredth.
I don't not what should i do. Add a new answer or edit that post. As the answer is highly ranked so i have made a new post with updating the code. I have just change this two things have mention above.
The output is