On Roman Numerals

Posted 3 months, 3 weeks ago | Originally written on 4 Jul 2020

OK. Quick note. I've just come across a Python package for converting Arabic to Roman numerals. Great! But I think it can be improved in several ways.

  1. Add documentation even if just in the README file to show how to use it.
  2. Add an entry point for users to run it in the terminal.
  3. Extend the range. It currently only does conversions up to 4999. However, one can actually write Roman numerals up to several million (I can't remember the exact bound) using some interesting tricks. An overline provides a thousands multiplier (https://blog.prepscholar.com/roman-numerals-converter). The main challenge here is how to add the overline. My immediate thought was to use a unicode character. However, that falls short quite fast because I don't think there's a V with overline. Anyway, even if there is what you can do is using COMBINING DIACRITICAL MARKS (https://www.unicode.org/charts/nameslist/n_0300.html). Here's some Python code:


In [2]: chr(0x0238)+chr(0x0304)
Out[2]: 'ȸ̄'

In [3]: chr(0x0238) #+chr(0x0304)
Out[3]: 'ȸ'


The basic idea is to append the diacritical mark immediately after whatever symbol you want with an overline. The example above uses the COMBINING MACRON but you can get better results (continuous overline) using the COMBINING OVERLINE like so:

In [7]: 'V'+chr(0x0305)
Out[7]: 'V̅'

In [8]: 'I'+chr(0x0305) + 'V'+chr(0x0305)
Out[8]: 'I̅V̅'

I plan to add these features to the Python roman package.