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

package main

import "fmt"

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

Output: 65

@robpike
Copy link
Contributor

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 as completed May 14, 2020
@golang golang locked and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants