Problem 44955. Spell the number

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

28.57% Correct | 71.43% Incorrect
Last Solution submitted on Jul 18, 2023

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers4

Suggested Problems

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!