mirror of
https://github.com/rwinkhart/convertroman.git
synced 2026-09-06 00:47:16 -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.
|
// 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 {
|
func FromInt(input int) string {
|
||||||
// check the range of the input integer
|
// check the range of the input integer
|
||||||
if input < 1 {
|
if input < 1 {
|
||||||
return "0"
|
return "0"
|
||||||
} else if input < 4000 {
|
} else if input < 4000 {
|
||||||
return baseRange(input)
|
return baseRange(input)
|
||||||
} else {
|
} else if input < 4000000 {
|
||||||
thousands, remainder := separateThousands(input)
|
thousands, remainder := separateThousands(input)
|
||||||
return vinculumRange(thousands) + baseRange(remainder)
|
return vinculumRange(thousands) + baseRange(remainder)
|
||||||
|
} else {
|
||||||
|
return "OOB"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user