-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ToInt have bad case #216
Comments
Cast package treats this value as an octal number. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for example,string is "00011",handle ToInt("00011"),want to get int value is 11,now return 9;
need exchange caste.go trimZeroDecimal method,first trimleft zero
func trimZeroDecimal(s string) string {
s = strings.TrimLeft(s, "0")
var foundZero bool
for i := len(s); i > 0; i-- {
switch s[i-1] {
case '.':
if foundZero {
return s[:i-1]
}
case '0':
foundZero = true
default:
return s
}
}
return s
}
The text was updated successfully, but these errors were encountered: