1.0.1 • Published 2 years ago

roman-standard-form v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

roman-standard-form Language Typescript Code Coverage

Helper functions for working with roman numerals.

Roman numerals

Roman numerals are essentially a decimal number system, but instead of place value notation (in which place-keeping zeros enable a digit to represent different powers of ten) the system uses a set of symbols with fixed values, including "built in" powers of ten. Tally-like combinations of these fixed symbols correspond to the (placed) digits of Arabic numerals. This structure allows for significant flexibility in notation, and many variant forms are attested.

There has never been an official or universally accepted standard for Roman numerals. Usage in ancient Rome varied greatly and became thoroughly chaotic in medieval times. Even the post-renaissance restoration of a largely "classical" notation has failed to produce total consistency: variant forms are even defended by some modern writers as offering improved "flexibility". On the other hand, especially where a Roman numeral is considered a legally binding expression of a number, as in U.S. Copyright law (where an "incorrect" or ambiguous numeral may invalidate a copyright claim, or affect the termination date of the copyright period) it is desirable to strictly follow the usual style described below.

Standard form

The following table displays how Roman numerals are usually written.

ThousandsHundredsTensUnits
1MCXI
2MMCCXXII
3MMMCCCXXXIII
4CDXLIV
5DLV
6DCLXVI
7DCCLXXVII
8DCCCLXXXVIII
9CMXCIX

The numerals for 4 (IV) and 9 (IX) are written using "subtractive notation", where the first symbol (I) is subtracted from the larger one (V, or X), thus avoiding the clumsier (IIII, and VIIII). Subtractive notation is also used for 40 (XL), 90 (XC), 400 (CD) and 900 (CM).These are the only subtractive forms in standard use.

Usage/Examples

romanNumeral.fromDecimal()

import romanNumeral from 'roman-standard-form';
...
const year = 2022;
const result = romanNumeral.fromDecimal(year);
console.log(result); // will print 'MMXXII'
...

romanNumeral.toDecimal()

import romanNumeral from 'roman-standard-form';
...
const roman = "MMXXII";
const result = romanNumeral.toDecimal(roman);
console.log(result); // will print 2022
...

Authors