You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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: