cast icon indicating copy to clipboard operation
cast copied to clipboard

why cast.ToInt("08") return 0 then cast.ToInt("07") return 7 ?

Open maogou opened this issue 1 year ago • 1 comments

run cast.ToInt("08") return 0 cast.ToInt("07") return 7 ?

my go version is go1.22.0

maogou avatar Aug 01 '24 02:08 maogou

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.

yamadev11 avatar Jan 08 '25 18:01 yamadev11

thank you

maogou avatar Jul 18 '25 01:07 maogou