mirror of
https://github.com/rwinkhart/convertroman.git
synced 2026-08-28 04:46:32 -04:00
Properly cap vinculum range at 3,999,999
This commit is contained in:
+6
-1
@@ -10,15 +10,20 @@ var (
|
||||
)
|
||||
|
||||
// FromInt converts an integer value to a roman numeral string.
|
||||
// The function will return "0" if the input integer is less than 1.
|
||||
// The function will return "OOB" if the input integer is greater than
|
||||
// or equal to 4,000,000 (the roman numeral vinculum limit).
|
||||
func FromInt(input int) string {
|
||||
// check the range of the input integer
|
||||
if input < 1 {
|
||||
return "0"
|
||||
} else if input < 4000 {
|
||||
return baseRange(input)
|
||||
} else {
|
||||
} else if input < 4000000 {
|
||||
thousands, remainder := separateThousands(input)
|
||||
return vinculumRange(thousands) + baseRange(remainder)
|
||||
} else {
|
||||
return "OOB"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user