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?
This is another way...(with limited range)
I think that this solution is not the best, since it works only for
int
, but i think it's great for a beginner.The test creates 20 random numbers up to
Integer.MAX_VALUE
and than some that know to be problematic, because of 0, 10, etc.. Output:Hope it helps :)
Test