printfn / fend

Arbitrary-precision unit-aware calculator
https://printfn.github.io/fend
MIT License
587 stars 50 forks source link

Roman numerals don't scale well beyond 1,000 #282

Open haykam821 opened 3 months ago

haykam821 commented 3 months ago

When converting numbers to Roman numerals, the maximum Roman numeral implemented is M:

> 10000 to roman
MMMMMMMMMM
> 100000 to roman
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM

Sufficiently big numbers over 1,000 can result in the REPL freezing, and the maximum Roman numeral representation is over 4 million characters long.

Would it make sense to use the overline to represent larger quantities? For example, a combining overline would give a larger buffer before the output becomes nonsense, and a combining double overline would give an even larger buffer.

printfn commented 3 months ago

Interesting, I didn't know overlines were used for larger numbers. I agree this would probably make sense to implement.

printfn commented 3 months ago

For now I've implemented an upper bound of 100,000, which prevents the REPL from freezing or running out of memory. Adding support for larger numbers with different notation would obviously still be a good idea :)