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

Add 0 before int type value, it will be converted to other values #39068

Closed
geiverhuang opened this issue May 14, 2020 · 1 comment
Closed

Add 0 before int type value, it will be converted to other values #39068

geiverhuang opened this issue May 14, 2020 · 1 comment

Comments

@geiverhuang
Copy link

@geiverhuang geiverhuang commented May 14, 2020

package main

import "fmt"

func main() {
var a int = 0101
fmt.Println(a)
}

Output: 65

@robpike
Copy link
Contributor

@robpike robpike commented May 14, 2020

Working as intended. The leading 0 creates an octal constant. See the integer literals section of the Go language specification.

https://golang.org/ref/spec#Integer_literals

@robpike robpike closed this May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.