Ask coding questions

← Back to all posts
Why Doesn't XIV follow the Normal Rules?
SUHASTADIPARTH1 (182)

Hi, I am trying to decode roman numerals with python, and it works for all other numbers such as "IV" or "MMVIII". But for "XIV", I am getting 16, while the answer should be 14. According to the rules, you should add if a small number comes after a big number. And if a big number comes after a small number you should subtract. So I am not sure why "XIV" doesn't follow that!

Can you please explain the process?
Thank you!

Answered by LukeWright (114) [earned 5 cycles]
View Answer
Comments
hotnewtop
LukeWright (114)

XIV would be 10 + ( 5 - 1 ) = 14. There is probably an error in whatever translator you are using. Why don't you try to code your own?

SUHASTADIPARTH1 (182)

@LukeWright I tried, but it didn't work. And why did you subtract 5-1. I thought, when a small number comes after a big number, you should add.

LukeWright (114)

yes that is correct, but in this case I = 1 and V = 5. The small number is coming before the bigger number so you subtract. Therefore IV = 4 and VI = 6 @SUHASTADIPARTH1

LukeWright (114)

This would also hold true for other numerals. For example C = 100 and X = 10. XC would be 90 and CX would be 110 @SUHASTADIPARTH1

SUHASTADIPARTH1 (182)

@LukeWright I see!, but i thought it goes from left to right. 10 => 1 => 5. 10 + 1 = 11 and 11 => 5!

SUHASTADIPARTH1 (182)

@LukeWright So, do you have to simply the small numbers first before adding the big ones?

LukeWright (114)

also, to answer your previous question, in plain english, XIV would be (10)(1)(5) where X = 10, I = 1, and V = 5
to create other numbers, different combinations of the different roman numberals are used. Here is 1-10 in Roman Numerals
I = 1
II = 2
III = 3
IV = 4
V = 5
VI = 6
VII = 7
VIII = 8
IX = 9
X = 10
@SUHASTADIPARTH1

SUHASTADIPARTH1 (182)

@LukeWright Yup. I get it now! So, you to simply/combine/subtract the small numbers and move on to the big ones!

LukeWright (114)

It does go from left to right, but any time you see a smaller number to the left of a bigger number, you subtract the smaller number from the bigger number. @SUHASTADIPARTH1

LukeWright (114)

Although if you are trying to read ancient roman, don't forget that
A bar above a numeral means multiply it by 1,000

and that sometimes ancient romans use double subtractives

SUHASTADIPARTH1 (182)

@LukeWright Ok, thank you! I will try out what you told in my code! I will let you know if it works!

idrgplayer (128)

I thought that x = 10, i = 1, and v = 5. maybe that is why.

idrgplayer (128)

@SUHASTADIPARTH1 yeah so whats the problem? i dont understand

SUHASTADIPARTH1 (182)

@idrgplayer, Yes x = 10, i = 1, and v = 5. So 10 + 1 + 5 = 16. But the answer is not 16, the actual answer is 14. That's what I don't understand. Why is it 14 instead of 16?

idrgplayer (128)

@SUHASTADIPARTH1 ohhh u wrote i am getting 16, while the answer should be 14 so i read it wrong.

SUHASTADIPARTH1 (182)

@idrgplayer Yes! I was wondering why it is 14!