
Calling Sequence


convert(n, roman, opts)


Parameters


n



positive integer

opts



(optional) equation(s) of the form option=value where option is one of large, period, or symbol; specify options for the conversion





Description


•

The convert(n, roman) function converts the positive integer n to the Roman numeral represented as a string.

•

The following table gives the Roman letters representing various integers.

Letter

Value

I

1

V

5

X

10

L

50

C

100

D

500

M

1000



•

Give a value $N$ where $N$ is a power of 10. To write the value for either $2N$, $3N$, or $4N$, repeat the Roman numeral for $N$ either $2$, $3$, or $4$ times. For example, $2$, $30$, $400$ can be represented by II, XXX and CCCC, respectively.

•

Give a value $N$ where $N$ is a power of 10. To write the value for either $6N$, $7N$, $8N$, or $9N$, write the Roman numeral for $5N$ followed by the Roman numeral for $N$ either $1$, $2$, $3$, or $4$ times. For example, $6$, $70$, $900$ are represented by VI, LXX, and DCCCC, respectively.

•

There is a modification to writing Roman numerals for numbers that are a power of $10$ multiplied by $4$ or $9$. The Roman numeral for $4N$ or $9N$ is written as $N$ followed by the Roman numeral for $5N$ or $10N$, respectively. For example, $4$, $9$, $40$, and $900$ can be represented by IV, IX, XL, and CM, respectively. This modification was introduced near the end of the Republic.

•

All other numbers are created by taking these multiples and placing them together with the largest value on the left and smallest value on the right. For example, $1527$ is the sum of $1000$, $500$, $20$, and $7$, which are represented by M, D, XX, and VII, forming MDXXVII.


Originally, the Roman numerals for $500$ and $1000$ were represented as I9 and CI9 where the $9$ is used in place of a backwards C, or apostrophus. Further multiples of 10 were denoted by adding an extra apostrophus for multiples of $500$ and surrounding CI9 by another C and 9 pair. The following table gives these values up to one million:

Value

Historic Roman Number

500

I9

1000

CI9

5000

I99

10 000

CCI99

50 000

I999

100 000

CCCI999




Values greater than $100000$ have not been observed historically.


Over time, the I9 was simplified to D and the CI9 was replaced by an M. With this new format, the logarithmic method of denoting larger numbers was lost. To denote values like $12000$, it was necessary to use MMMMMMMMMMMM.


To solve this problem, drawing a horizontal line (or vinculum, titulus) over V, X, L, and C indicates a multiple of $1000$ of these numbers. Thus, 97607 would be written as:


There is no historical evidence that a further multiple of $1000$ could be indicated by a second line.


The values $500000$ and $1000000$ were represented by Q (from quingenta milia) and a box around the letter X (for decies centena milia, or 10 hundred thousand), respectively. There is no historical evidence that a C surrounded by a box is intended to represent $10000000$.


Other unsupported formats are:

1.

Using a C instead of an apostrophus, for example, IC and CIC for $500$ and $1000$, respectively.

2.

Using an infinity or a capital Phi symbol for $1000$.

3.

Writing multiples of $1000$ by prefixing an M by the multiple, for example, $7000$ would be VII M.

4.

Using subtractive notation while using apostrophi, but this would require spacing to avoid confusion, for example, C I9 is $400$ but CI9 is $1000$.

5.

Using double subtraction, for example, IIX and CCM instead of VIII and DCCC to represent $8$ and $800$, respectively.

•

You can modify the properties of the conversion by including options opts. The opts argument can contain one or more of the following equations.


period = early, middle, or late


In early times, all values were displayed using the additive format. In the transition, it was still common to use the additive format for values $4$ and $9$ but the subtractive format for larger values. In the late period, almost all numbers were written using the subtractive format exclusively. Clock faces (using IIII for $4$ is one exception.)


large = apostrophus or repeated


By default, large numbers are created by repeating an M sufficiently many times. If this option is set to apostrophus, the older version using CI9 to represent $1000$ is used. For ease of reading, values greater than $100$ are separated by spaces.


The default output is a string. If the option symbol is set to true, then the result is a symbol.



Examples


>

$\mathrm{convert}\left(2849\,\mathrm{roman}\right)$

>

$\mathrm{convert}\left(2849\,\mathrm{roman}\,\mathrm{period}\=\mathrm{early}\,\mathrm{symbol}\right)$

${\mathrm{MMDCCCXXXXVIIII}}$
 (2) 
>

$\mathrm{convert}\left(35034\,\mathrm{roman}\,\mathrm{large}\=\mathrm{apostrophus}\right)$

${''CCI99\; CCI99\; CCI99\; I99\; XXXIV''}$
 (3) 
>

$\mathrm{plots}\[\mathrm{listplot}\]\left(\left[\mathrm{seq}\left(\mathrm{length}\left(\mathrm{convert}\left(i\,\mathrm{roman}\,\mathrm{large}\=\mathrm{apostrophus}\right)\right)\,i\=1..2400\right)\right]\right)$



