Using the British short scale notation, write a function to return the correct spelling of a number passed as a numeric string including decimal places. The function should be able to accept spaces, commas and leading zeros. Numbers beginning with '.' should return 'Zero point something' and numbers ending in '.' should state only the integer part.
Examples:
'10007.76' should return 'Ten thousand and seven point seven six' '001102.34' should return 'One thousand one hundred and two point three four' '.4' should return 'Zero point four' '4.' should return 'Four' '0.' and '.' should return 'Zero' '340,139' should return 'Three hundred and forty thousand one hundred and thirty nine'
In the British short scale notation:
1 Hundred = 10^2 1 Thousand = 10^3 1 Million = 10^6 1 Billion = 10^9 1 Trillion = 10^12 1 Quadrillion = 10^15 1 Quintillion = 10^18 1 Sextillion = 10^21 1 Septillion = 10^24 1 Octillion = 10^27 1 Nonillion = 10^30 1 Decillion = 10^33 1 Vigintillion = 10^63 1 Centillion = 10^303
Solution Stats
Problem Comments
1 Comment
Solution Comments
Show comments
Loading...
Problem Recent Solvers4
Suggested Problems
-
Project Euler: Problem 10, Sum of Primes
2088 Solvers
-
Number of 1s in a binary string
10963 Solvers
-
739 Solvers
-
474 Solvers
-
775 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
It would be nice if you didn't disallow regular expressions for this kind of problem; text manipulation is exactly what regular expressions are for, after all.