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" } };
30 std::string roman =
"";
31 roman.reserve(length);
33 for ( power = 0; power < nrows; power++ )
34 for ( index = 0; index < ncols; index++ )
35 while ( decimal >= table_arabs[ power ][ index ] )
37 roman += table_romans[ power ][ index ];
38 decimal -= table_arabs[ power ][ index ];