1 #include <OpenMesh/Core/System/config.hh>
2 #if defined(OM_CC_MIPS)
7 #include "int2roman.hh"
10 std::string int2roman(
size_t decimal,
size_t length )
12 assert( decimal > 0 && decimal < 1000 );
14 const size_t nrows = 4;
15 const size_t ncols = 4;
17 static size_t table_arabs[ nrows ][ ncols ] = { { 1000, 1000, 1000, 1000 },
18 { 900, 500, 400, 100 },
22 static char *table_romans[ nrows ][ ncols ] = { {
"M",
"M",
"M",
"M" },
23 {
"CM",
"D",
"CD",
"C" },
24 {
"XC",
"L",
"XL",
"X" },
25 {
"IX",
"V",
"IV",
"I" } };
32 roman.reserve(length);
36 for ( power = 0; power < nrows; power++ )
37 for ( index = 0; index < ncols; index++ )
38 while ( decimal >= table_arabs[ power ][ index ] )
40 roman += table_romans[ power ][ index ];
41 decimal -= table_arabs[ power ][ index ];