The Roman numeral system is an ancient way of representing numbers. The base symbols are I (1), V (5), X (10), L (50), C (100), D (500) and M (1000).
Questions tagged [roman-numerals]
273 questions
9
votes
7 answers
Roman to Integer - But using a "different" Roman number system
I had an interview in which I did terribly. So, now I'm trying to find the solution to the question. Here is the interview question:
"We have the following mapping:
M: 1000, D: 500, C: 100, L: 50, X: 10, V: 5, I: 1.
And we have the following…

user224567893
- 636
- 4
- 18
- 28
9
votes
3 answers
Convert integers to roman numerals using a syntax-directed translation scheme?
The Dragon Book includes an exercise on converting integers to roman numerals using a syntax-directed translation scheme.
How can this be completed?

Daniel Magliola
- 30,898
- 61
- 164
- 243
8
votes
5 answers
latex: printing a variable in roman numerals
I'm typesetting in LaTeX, and I'd like to display a "variable" (in my case, a reference \ref{blah} to an item number in list) in roman rather than the default arabic. Is there an easy way to do this? Thanks for any pointers!

anon
- 235
- 2
- 9
7
votes
1 answer
Roman Numeral to integer function
basically i am trying to create a function that will turn a Roman numeral into a integer.
I have an array:
$roman_numerals=[
'M' => 1000,
'CM' => 900,
'D' => 500,
'CD' => 400,
'C' => 100,
'XC' => 90,
'L' => 50,
…

Kolvin
- 185
- 2
- 16
7
votes
3 answers
I am trying to figure out how to convert roman numerals into integers
I am trying to figure out how to convert roman numerals to integers. This is a portion of my code. When I prompt the user to enter M it shows 1000, but when I prompt the user to enter a roman numeral such as VM, it does not give me 995 but instead…

Zoro
- 695
- 2
- 7
- 23
6
votes
3 answers
Objective C Number to Roman Numerals
I've been searching forever for some sample code on convert from a number to roman numerals in objective c. Anyone know where I can find a good example?
Update:
Nevermind, found a PHP function that does what I want and ported it. Seems to work fine…

enamrik
- 2,292
- 2
- 27
- 42
6
votes
4 answers
Can this Roman Number to Integer converter code be shorter?
95 bytes currently in python
I,V,X,L,C,D,M,R,r=1,5,10,50,100,500,1000,vars(),lambda x:reduce(lambda T,x:T+R[x]-T%R[x]*2,x,0)
Here is the few test results, it should work for 1 to 3999 (assume input is valid char only)
>>> r("I")
1
>>>…

YOU
- 120,166
- 34
- 186
- 219
5
votes
2 answers
Convert arabic numerals in roman numerals in pure CSS
I'm writing a custom theme for a website, so I cannot use Javascript. I would like to convert some numbers to roman numerals.
I tried this:
.score:before {
counter-reset: mycounter attr(score number, 0);
content: counter(mycounter,…

Antoine Pietri
- 793
- 1
- 10
- 25
5
votes
16 answers
Roman to Integer in JS why it only convert the first character
I try to solve the Leedcode question 13 and the question is Given a roman numeral, convert it to an integer.(Input is guaranteed to be within the range from 1 to 3999.)
This is my code below, I wonder why it only converts the first character in the…

cece
- 67
- 1
- 1
- 5
5
votes
1 answer
How to check if a string contains roman numerals in R?
I have a column for residential adresses in my dataset 'ad'. I want to check for addresses which has no numbers(including roman numerals) present.
I'm using
ad$check <- grepl("[[:digit:]]",ad$address)
to flag out addresses with no digits present.…

Priya T
- 63
- 5
5
votes
2 answers
prolog convert numbers into roman numerals
i have this code that converts integers into roman numerals
i need to add a function that compares an integer with a roman numeral input and show if it's try or false, for example:
roman(v,5).
true
toroman(0).
toroman(N) :- N < 4, put("I"), M is N…

Muhsag
- 155
- 3
- 11
5
votes
3 answers
FormatProvider vs. extension method vs. new class
I was wanting to output an integer to roman numerals and ran across this answer by Jesse Slicer. It is an extension method, but I was wondering about taking advantage of ToString(string, IFormatProvider) to do something like
int a = 10;
string b =…

Colin Burnett
- 11,150
- 6
- 31
- 40
4
votes
3 answers
How to create regular expression checking Roman numerals?
I need to create regular expression which verifies if user inputs:
4 digits OR
value like XXXXXX-YY, where X is roman numerals from I to XXXIII and YY is two latin characters (A-Z)

LA_
- 19,823
- 58
- 172
- 308
4
votes
1 answer
Matching Roman Numbers
I have regular expression
(IX|IV|V?I{0,3}|M{1,4}|CM|CD|D?C{1,3}|XC|XL|L?X{1,3})
I use it to detect if there is any roman number in text.
eregi("( IX|IV|V?I{0,3}[\.]| M{1,4}[\.]| CM|CD|D?C{1,3}[\.]| XC|XL|L?X{1,3}[\.])", $title, $regs)
But format…

M.V.
- 1,662
- 8
- 32
- 55
4
votes
3 answers
.NET naming standard for class names with Roman numerals
I am working on a new project that involves government funding. As such we will have objects (classes, properties, methods) that reference government legislation which have names like Title II, Title IV-A, Title IX, Title XVI, etc.
We are following…

jovball
- 126
- 1
- 6