Decimal number to roman numeral
Author Message
Decimal number to roman numeral

Does anyone have a routine that converts a decimal number to roman numerals
that you wouldn't mind sharing with me?

I'd appreciate it. Thanks.

Doug

Sun, 04 Sep 2005 00:15:18 GMT
Decimal number to roman numeral
From Louis de Lacroix

PROCEDURE Romain
PARAMETERS tn
* Convertit en romain un entier < 10000
DO CASE
CASE tn<10
DO CASE
CASE tn=0
RETURN ""
CASE tn>=1 AND tn<4
RETURN "I"+romain(tn-1)
CASE tn=4
RETURN "IV"
CASE tn>=5 AND tn<9
RETURN "V"+romain(tn-5)
CASE tn=9
RETURN "IX"
ENDCASE
CASE tn>=10 AND tn<100
DO CASE
CASE tn<40
RETURN "X"+romain(tn-10)
CASE tn>=40 AND tn<50
RETURN "XL"+romain(tn-40)
CASE tn>=50 AND tn<90
RETURN "L"+romain(tn-50)
CASE tn>=90
RETURN "XC"+romain(tn-90)
ENDCASE
CASE tn>=100 AND tn<1000
DO CASE
CASE tn<400
RETURN "C"+romain(tn-100)
CASE tn>=400 AND tn<500
RETURN "CD"+romain(tn-400)
CASE tn>=500 AND tn<900
RETURN "D"+romain(tn-500)
CASE tn>=900
RETURN "CM"+romain(tn-900)
ENDCASE
CASE tn>=1000 AND tn<10000
RETURN "M"+romain(tn-1000)
OTHERWISE  && Si on a besoin de plus, on peut facilement adapter
WAIT WINDOW "out of range..."  TIMEOUT 5 &&"Nombre trop grand... Programme
romain modifier"
ENDCASE

Enjoy!

Fred

Bonjour Doug Allan
Pour mmoire, tu nous as crit :

Quote:
> Does anyone have a routine that converts a decimal number to roman
> numerals that you wouldn't mind sharing with me?

> I'd appreciate it. Thanks.

> Doug

Sun, 04 Sep 2005 01:14:58 GMT
Decimal number to roman numeral
Hi Fred;

Thanks very much for the code. I really appreciate it.

Doug

Quote:
> From Louis de Lacroix

> PROCEDURE Romain
> PARAMETERS tn
> * Convertit en romain un entier < 10000
> DO CASE
>  CASE tn<10
>   DO CASE
>    CASE tn=0
>     RETURN ""
>    CASE tn>=1 AND tn<4
>     RETURN "I"+romain(tn-1)
>    CASE tn=4
>     RETURN "IV"
>    CASE tn>=5 AND tn<9
>     RETURN "V"+romain(tn-5)
>    CASE tn=9
>     RETURN "IX"
>   ENDCASE
>  CASE tn>=10 AND tn<100
>   DO CASE
>    CASE tn<40
>     RETURN "X"+romain(tn-10)
>    CASE tn>=40 AND tn<50
>     RETURN "XL"+romain(tn-40)
>    CASE tn>=50 AND tn<90
>     RETURN "L"+romain(tn-50)
>    CASE tn>=90
>     RETURN "XC"+romain(tn-90)
>    ENDCASE
>  CASE tn>=100 AND tn<1000
>   DO CASE
>    CASE tn<400
>     RETURN "C"+romain(tn-100)
>    CASE tn>=400 AND tn<500
>     RETURN "CD"+romain(tn-400)
>    CASE tn>=500 AND tn<900
>     RETURN "D"+romain(tn-500)
>    CASE tn>=900
>     RETURN "CM"+romain(tn-900)
>    ENDCASE
>  CASE tn>=1000 AND tn<10000
>     RETURN "M"+romain(tn-1000)
>  OTHERWISE  && Si on a besoin de plus, on peut facilement adapter
>   WAIT WINDOW "out of range..."  TIMEOUT 5 &&"Nombre trop grand...
Programme
> romain modifier"
> ENDCASE

> Enjoy!

> Fred

> Bonjour Doug Allan
> Pour mmoire, tu nous as crit :

> > Does anyone have a routine that converts a decimal number to roman
> > numerals that you wouldn't mind sharing with me?

> > I'd appreciate it. Thanks.

> > Doug

Sun, 04 Sep 2005 02:43:08 GMT
Decimal number to roman numeral
Thanks to our Louis national then ;)

Bonjour Doug Allan
Pour mmoire, tu nous as crit :

Quote:
> Hi Fred;

> Thanks very much for the code. I really appreciate it.

> Doug

>> From Louis de Lacroix

>> PROCEDURE Romain
>> PARAMETERS tn
>> * Convertit en romain un entier < 10000
>> DO CASE
>>  CASE tn<10
>>   DO CASE
>>    CASE tn=0
>>     RETURN ""
>>    CASE tn>=1 AND tn<4
>>     RETURN "I"+romain(tn-1)
>>    CASE tn=4
>>     RETURN "IV"
>>    CASE tn>=5 AND tn<9
>>     RETURN "V"+romain(tn-5)
>>    CASE tn=9
>>     RETURN "IX"
>>   ENDCASE
>>  CASE tn>=10 AND tn<100
>>   DO CASE
>>    CASE tn<40
>>     RETURN "X"+romain(tn-10)
>>    CASE tn>=40 AND tn<50
>>     RETURN "XL"+romain(tn-40)
>>    CASE tn>=50 AND tn<90
>>     RETURN "L"+romain(tn-50)
>>    CASE tn>=90
>>     RETURN "XC"+romain(tn-90)
>>    ENDCASE
>>  CASE tn>=100 AND tn<1000
>>   DO CASE
>>    CASE tn<400
>>     RETURN "C"+romain(tn-100)
>>    CASE tn>=400 AND tn<500
>>     RETURN "CD"+romain(tn-400)
>>    CASE tn>=500 AND tn<900
>>     RETURN "D"+romain(tn-500)
>>    CASE tn>=900
>>     RETURN "CM"+romain(tn-900)
>>    ENDCASE
>>  CASE tn>=1000 AND tn<10000
>>     RETURN "M"+romain(tn-1000)
>>  OTHERWISE  && Si on a besoin de plus, on peut facilement adapter
>>   WAIT WINDOW "out of range..."  TIMEOUT 5 &&"Nombre trop grand...
>> Programme romain modifier"
>> ENDCASE

>> Enjoy!

>> Fred

>> Bonjour Doug Allan
>> Pour mmoire, tu nous as crit :

>>> Does anyone have a routine that converts a decimal number to roman
>>> numerals that you wouldn't mind sharing with me?

>>> I'd appreciate it. Thanks.

>>> Doug

Sun, 04 Sep 2005 15:43:00 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages