convert/roman - convert positive integers to Roman numerals
|
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.
|
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.
|
|
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
|
|
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
|
|
>
|
|
| (1) |
>
|
|
| (2) |
>
|
|
| (3) |
>
|
|
|
|