intToRomanNumeral function
Converts an integer to its Roman numeral representation.
Supports values from 1 to 3999. Values outside this range throw
ArgumentError since Roman numerals cannot represent zero or negatives,
and values 4000+ require special notation.
Example: intToRomanNumeral(42) returns 'XLII'.
Implementation
String intToRomanNumeral(int value) {
if (value <= 0 || value >= 4000) {
throw ArgumentError('Value must be between 1 and 3999');
}
var num = value;
final result = StringBuffer();
_romanNumeralParts.forEach((entryValue, numeral) {
while (num >= entryValue) {
result.write(numeral);
num -= entryValue;
}
});
return result.toString();
}