Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Converting roman numerals to decimal numbers is harder than it sounds...
PHP
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
README.textile
RomanNumeral.php
RomanNumeralTest.php

README.textile

Roman Numerals

Given a Roman numeral, convert to Decimal format; given a Decimal number, convert to Roman numeral.

Decimal values for Roman Numerals

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

Example data sets:

III = 1 + 1 + 1 = 3
VII = 5 + 1 + 1 = 7
IV = 5 – 1 = 4
LL = 50 + 50 = 100 = ERROR!
XX = 10 + 10 = 20
LC = 100 – 50 = 50 = ERROR!
MCMLVII = 1000 + ( 1000 – 100 ) + 50 + ( 5 + 1 + 1 ) = 1957
CC = 100 + 100 = 200
XC = 100 – 10 = 90
IC = 100 – 1 = 99 = ERROR

Proposed Classes

$Number = new RomanNumeral(‘XVII’);

$Number→toInt();

Something went wrong with that request. Please try again.