cast icon indicating copy to clipboard operation
cast copied to clipboard

ToInt have bad case

Open ypshe opened this issue 1 year ago • 1 comments

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 }

ypshe avatar Apr 15 '24 09:04 ypshe

Cast package treats this value as an octal number.

bagualing avatar Jun 28 '24 01:06 bagualing