Les chiffres romain bien que peut efficace sont très utilisés encore aujourd'hui pour numéroter des annexes, suite de films et des pages de prélude. Voici leur représentation classique :
Nombre Romain | Nombre décimal | Nombre octal | Nombre hexadécimal |
---|---|---|---|
I | 1 | 1 | 1 |
II | 2 | 2 | 2 |
III | 3 | 3 | 3 |
IV | 4 | 4 | 4 |
V | 5 | 5 | 5 |
VI | 6 | 6 | 6 |
VII | 7 | 7 | 7 |
VIII | 8 | 10 | 8 |
IX | 9 | 11 | 9 |
X | 10 | 12 | A |
XI | 11 | 13 | B |
XII | 12 | 14 | C |
XIII | 13 | 15 | D |
XIV | 14 | 16 | E |
XV | 15 | 17 | F |
... | ... | ... | ... |
Toutefois, il est a noter que les chiffres romain ne dépasse que de très peu les milliers en terme de numérotation. Pour pouvoir générer automatiquement les nombres à partir de l'équivalence numérique, vous trouverez la réponse que vous souhaitez, à l'aide du code source Ada suivant :
- WITH TEXT_IO;
- PROCEDURE Roman IS USE TEXT_IO;
-
- PROCEDURE AddStr(Source:IN OUT String;Add:IN String) IS
- Fin:Integer;
- BEGIN
- FOR I IN 1..Source'Length LOOP
- IF Source(I)=' 'THEN
- Fin:=I;
- END IF;
- EXIT WHEN Source(I)=' ';
- END LOOP;
- Source(Fin..Fin-1+Add'Length):=Add;
- END;
-
- FUNCTION NumberToRomain(X:IN Integer) RETURN String IS
- S:String(1..15);
- A:Integer;
- BEGIN
- S(1..15):=" ";
- CASE Integer((X mod 1000) / 100) IS
- WHEN 9 => AddStr(S,"CM");
- WHEN 8 => AddStr(S,"DCCC");
- WHEN 7 => AddStr(S,"DCC");
- WHEN 6 => AddStr(S,"DC");
- WHEN 5 => AddStr(S,"D");
- WHEN 4 => AddStr(S,"CD");
- WHEN 3 => AddStr(S,"CCC");
- WHEN 2 => AddStr(S,"CC");
- WHEN 1 => AddStr(S,"C");
- WHEN OTHERS => A:=1;
- END CASE;
- CASE Integer((X mod 100) / 10) IS
- WHEN 9 => AddStr(S,"XC");
- WHEN 8 => AddStr(S,"LXXX");
- WHEN 7 => AddStr(S,"LXX");
- WHEN 6 => AddStr(S,"LX");
- WHEN 5 => AddStr(S,"L");
- WHEN 4 => AddStr(S,"XL");
- WHEN 3 => AddStr(S,"XXX");
- WHEN 2 => AddStr(S,"XX");
- WHEN 1 => AddStr(S,"X");
- WHEN OTHERS => A:=1;
- END CASE;
- CASE X mod 10 IS
- WHEN 9 => AddStr(S,"IX");
- WHEN 8 => AddStr(S,"VIII");
- WHEN 7 => AddStr(S,"VII");
- WHEN 6 => AddStr(S,"VI");
- WHEN 5 => AddStr(S,"V");
- WHEN 4 => AddStr(S,"IV");
- WHEN 3 => AddStr(S,"III");
- WHEN 2 => AddStr(S,"II");
- WHEN 1 => AddStr(S,"I");
- WHEN OTHERS => A:=1;
- END CASE;
- RETURN S;
- END NumberToRomain;
-
- BEGIN
- FOR I IN 1..100 LOOP
- PUT_LINE(INTEGER'IMAGE(I) & " = " & NumberToRomain(I));
- END LOOP;
- END Roman;
on obtiendra le résultat suivant :
1 = I2 = II
3 = III
4 = IV
5 = V
6 = VI
7 = VII
8 = VIII
9 = IX
10 = X
11 = XI
12 = XII
13 = XIII
14 = XIV
15 = XV
16 = XVI
17 = XVII
18 = XVIII
19 = XIX
20 = XX
21 = XXI
22 = XXII
23 = XXIII
24 = XXIV
25 = XXV
26 = XXVI
27 = XXVII
28 = XXVIII
29 = XXIX
30 = XXX
31 = XXXI
32 = XXXII
33 = XXXIII
34 = XXXIV
35 = XXXV
36 = XXXVI
37 = XXXVII
38 = XXXVIII
39 = XXXIX
40 = XL
41 = XLI
42 = XLII
43 = XLIII
44 = XLIV
45 = XLV
46 = XLVI
47 = XLVII
48 = XLVIII
49 = XLIX
50 = L
51 = LI
52 = LII
53 = LIII
54 = LIV
55 = LV
56 = LVI
57 = LVII
58 = LVIII
59 = LIX
60 = LX
61 = LXI
62 = LXII
63 = LXIII
64 = LXIV
65 = LXV
66 = LXVI
67 = LXVII
68 = LXVIII
69 = LXIX
70 = LXX
71 = LXXI
72 = LXXII
73 = LXXIII
74 = LXXIV
75 = LXXV
76 = LXXVI
77 = LXXVII
78 = LXXVIII
79 = LXXIX
80 = LXXX
81 = LXXXI
82 = LXXXII
83 = LXXXIII
84 = LXXXIV
85 = LXXXV
86 = LXXXVI
87 = LXXXVII
88 = LXXXVIII
89 = LXXXIX
90 = XC
91 = XCI
92 = XCII
93 = XCIII
94 = XCIV
95 = XCV
96 = XCVI
97 = XCVII
98 = XCVIII
99 = XCIX
100 = C
Dernière mise à jour : Samedi, le 25 août 2012