Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

defining a struct to associate roman numerals value 1

Status
Not open for further replies.

chineerat

Technical User
Oct 12, 2003
42
TT
hello there, i am wondering if there is an easier way to do this.
basically i am creating a vector of type structure and structure has types integer and string.

bascially the structure will have the roman numeral and its associated decimal value eg.

int string
1 I
5 V
10 X

etc.
and of course the first element of the vector will be integer 1 and string I
the second element will integer 5 and string V
and etc.

Am I doing something that already has been done or is this the only way to this?

thanks in adavnace
 
Is it just a lookup or do you want to convert integers to Roman Numerals at the end of the day.
 
yes!
i'll like to convert integers to Roman Numerals. why? am i approaching it wrongly if i do it like this?
 
There are many ways of skinning a cat: there is no wrong way and no right way. Algorithm development is a learning process. Sometimes we need to reinvent the wheel just for the satisfaction of thinking that we would have been able to do it even if nobody had told us how. Sometimes, the methods we invent are simpler than anything published.

Alternatively, if you want a simple algorithm, there is one in


but it is in VBScript. It is simpler than all the ones I've seen so far. I first devised the algorithm in VbScript so that is the one on the site. It is quite easy translating it to other languages. I've used it in BCPL, JavaScript, Fortran, Perl, Java, Assembler to name a few.

Shouldn't be too difficult translating it. The range is 1 to 3999. There is a problem printing Roman numerals bigger than 3999. For one, even the Romans are totally inconsistent on this. If you use the overscore notation, the problem is getting it to display correctly since there is no equivalent ANSI/UTF-8/UTF-16/Unicode character.
 
aye thanks guys!!
while you're at it, can you redirect me to a roman to arabic conversion?
thanks alot!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top