cast
cast copied to clipboard
why cast.ToInt("08") return 0 then cast.ToInt("07") return 7 ?
run cast.ToInt("08") return 0 cast.ToInt("07") return 7 ?
my go version is go1.22.0
Most programming languages of the C-family including Go treat integer numbers as octal if starting with 0 and hex if starting with 0x. Here it is starting with 0 hence considered as octal but decimal and resulted into different number than your expectation.
thank you