Numbers_Roman provides methods to convert Arabic numbers like 23 into Roman numerals like XXIII and back.
Note: Both class methods are static; you do not need to instantiate an object.
The static method toNumeral does exactly this.
It can be used for numbers from 1 to
5 999 999.
Using it to convert higher numbers works, but does not produce historically
correct results.
The second parameter $uppercase determines if the letters should be UPPERCASE (default) or not. Parameter number 3 sets if HTML code for overscores shall be generated; this is necessary for numbers greater than 3999. If the parameter is set to false, letters will be prefixed with an underscore _.
Using the static method toNumber you can convert Roman
numerals like XLII to Arabic numbers like
42.
Letters prefixed with an underscore represent numbers larger than 1000.
Table 55-1. Conversion Table: Roman letter to Arabic number
| Roman | Arabic |
|---|---|
| I | 1 |
| V | 5 |
| X | 10 |
| L | 50 |
| C | 100 |
| D | 500 |
| M | 1000 |
| S, _V | 5000 |
| R, _X | 10 000 |
| P, _L | 50 000 |
| Q, _C | 100 000 |
| O, _D | 500 000 |
| N, _M | 1 000 000 |