Leonardo da Pisano a.k.a Fibonacci was instrumental in bringing the Hindu-Arabic numeral system into Europe. Before that, mathematicians there worked in base sixty with Roman numerals.
For example, the square root of two might be approximated as: one and twenty-four parts of sixty and fifty-one parts of three-thousand-six-hundred, and written as: i xxiv li, with the scaling determined by context. At the time, “nothingness” was known (i.e. zero), but had no standard representation in this number system.
Had Fibonacci ignored these new-fangled decimal digits he encountered during his travels, he surely would have addressed the deficiencies in the current system. This improved system we'll call Fibonacci’s sexagesimals.
Your task is to write a program, function or code snippet which takes a floating point number in ASCII or binary format and outputs in base sixty Roman numerals. The input can be file, console, command line or function argument and output can be file or console, whichever is easiest.
The output can be upper or lower case, and must include these improvements:
- use n or N to indicate null meaning a place has no value, i.e. “zero” (a problem with the system)
- use e or E to indicate et corresponding to the sexagesimal point (another problem with the system)
- use a middle dot · or an asterisk * to separate groups of Roman numerals (yet another problem with the system)
Assume the input will be floating point with mantissa not greater than lix·lix·lix·lix·lix. Fractions less than n·e·n·n·n·n·i can be ignored. So, provided the input has these restrictions, at most ten groups of Roman numerals with one e can be outputted.
Numbers less than i must have a leading n·e to ensure the context is clear.
input → output
The output must avoid unnecessary leading n· in the mantissa part, isolated e, or trailing ·n in the fractional part of the output. So for example, n·n·n·n·i, i·e, and i·e·n·n·n·n·n are incorrect outputs for an input of
Differences of plus or minus n·e·n·n·n·n·i in the output are within tolerances and acceptable.
The input is any legal floating point in the language of your choice, so can include positive or negative exponents as long as the input doesn't fall outside the range specified above.
And finally, Roman numeral built-ins are allowed!