Skip to content

Collection of functions/methods to convert arabic numbers to/from roman numeral in JAVA, Javascript, SQL, C, C++, Perl. Rust, Dart and Python.

Notifications You must be signed in to change notification settings

gpalleschi/roman_numbers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

roman_numbers

Collection of functions/Methods to convert arabic numbers to/from roman numeral in JAVA, Javascript, SQL, C, C++, Perl, Python3, Dart and Rust.

Functions are :

decimalToRoman : From Decimal Number to Roman Number
romanToDecimal : From Roman Number to Decimal Number

Roman numerals are a numeral system that originated in ancient Rome and remained the usual way of writing numbers throughout Europe well into the Late Middle Ages. Numbers in this system are represented by combinations of letters from the Latin alphabet. Modern style uses seven symbols, each with a fixed integer value:

Symbol I V X L C D M
Value 1 5 10 50 100 500 1000

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.

A number containing two or more decimal digits is built by appending the Roman numeral equivalent for each, from highest to lowest, as in the following examples:

  39 = XXX + IX = XXXIX.  246 = CC + XL + VI = CCXLVI.  789 = DCC + LXXX + IX = DCCLXXXIX. 2,421 = MM + CD + XX + I = MMCDXXI.

Any missing place (represented by a zero in the place-value equivalent) is omitted, as in Latin (and English) speech:

 160 = C + LX = CLX  207 = CC + VII = CCVII 1,009 = M + IX = MIX 1,066 = M + LX + VI = MLXVI In practice, Roman numerals for numbers over 1000 are currently used mainly for year numbers, as in these examples:

1776 = M + DCC + LXX + VI = MDCCLXXVI (the date written on the book held by the Statue of Liberty). 1918 = M + CM + X + VIII = MCMXVIII (the first year of the Spanish flu pandemic) 1954 = M + CM + L + IV = MCMLIV (as in the trailer for the movie The Last Time I Saw Paris)[4] 2014 = MM + X + IV = MMXIV (the year of the games of the XXII (22nd) Olympic Winter Games (in Sochi, Russia)) The largest number that can be represented in this notation is 3,999 (MMMCMXCIX), but since the largest Roman numeral likely to be required today is MMXXII (the current year) there is no practical need for larger Roman numerals. Prior to the introduction of Arabic numerals in the West, ancient and medieval users of the system used various means to write larger numbers; see large numbers below.

About

Collection of functions/methods to convert arabic numbers to/from roman numeral in JAVA, Javascript, SQL, C, C++, Perl. Rust, Dart and Python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published