Skip to content
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

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

Open
maogou opened this issue Aug 1, 2024 · 1 comment
Open

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

maogou opened this issue Aug 1, 2024 · 1 comment

Comments

@maogou
Copy link

maogou commented Aug 1, 2024

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

my go version is go1.22.0

@yamadev11
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants