-
Notifications
You must be signed in to change notification settings - Fork 229
Open
Description
There's an important test case missing: DecToBase(0, ...). Same goes for BaseToDec.
In case of DecToBase(0, ...) an empty String is returned, which probably should be "0" instead.
I had to modify my recursive function - it now uses a helper function and duplicates some code:
const digits = "0123456789ABCDEF"
func _decToBase(dec, base int) string {
if dec == 0 {
return ""
}
digit := dec % base
return _decToBase(dec/base, base) + string(digits[digit])
}
func DecToBase(dec, base int) string {
digit := dec % base
return _decToBase(dec/base, base) + string(digits[digit])
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels