|
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 where is a power of 10. To write the value for either , , or , repeat the Roman numeral for either , , or times. For example, , , can be represented by II, XXX and CCCC, respectively.
|
•
|
Give a value where is a power of 10. To write the value for either , , , or , write the Roman numeral for followed by the Roman numeral for either , , , or times. For example, , , are represented by VI, LXX, and DCCCC, respectively.
|
•
|
There is a modification to writing Roman numerals for numbers that are a power of multiplied by or . The Roman numeral for or is written as followed by the Roman numeral for or , respectively. For example, , , , and 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, is the sum of , , , and , which are represented by M, D, XX, and VII, forming MDXXVII.
|
|
Originally, the Roman numerals for and were represented as I9 and CI9 where the is used in place of a backwards C, or apostrophus. Further multiples of 10 were denoted by adding an extra apostrophus for multiples of 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 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 , 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 of these numbers. Thus, 97607 would be written as:
|
|
There is no historical evidence that a further multiple of could be indicated by a second line.
|
|
The values and 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 .
|
|
Other unsupported formats are:
|
1.
|
Using a C instead of an apostrophus, for example, IC and CIC for and , respectively.
|
2.
|
Using an infinity or a capital Phi symbol for .
|
3.
|
Writing multiples of by prefixing an M by the multiple, for example, would be VII M.
|
4.
|
Using subtractive notation while using apostrophi, but this would require spacing to avoid confusion, for example, C I9 is but CI9 is .
|
5.
|
Using double subtraction, for example, IIX and CCM instead of VIII and DCCC to represent and , 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 and 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 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 is used. For ease of reading, values greater than 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
|
|
>
|
|
>
|
|
>
|
|
| (3) |
>
|
|
|
|
|