Is there a mathematical way to get the following:
For the the number 777,888,999 so 777 million and etc etc
getMillions(777888999) should return 777 only
getThousands(777888999) should return 888 only
getHundreds(777888999) should return 999 only
This should be done without using regex and without text processing but should be achieved using only mathematical operations.
I'm trying to solve a problem that may be familiar to some which is converting a number expressed in digits to words so 1 -> one, 10 -> ten, 100 -> one hundred etc
My thinking is that if I can convert a number up to 999 then the problem is pretty much solved as the rest will only append the words millions and/or thousands so
777888999 will covert to the words:
777 million and 888 thousands and 999 hundred
of course the above numbers will expressed in words.
This originally was given to me as part of a job interview process about a year ago. I am absolutely not using the solution here for a job application. But the above question is about number manipulation which I'm very interested in.