Literal

Integer literals

Integer literals express exact integer constants in decimal, binary, octal or hexadecimal. Underscores may separate digits and may follow a base prefix. A leading zero without a base letter uses legacy octal. Example output: '42 10 42 42 1000'.

Formal Syntax & Structure

go syntaxgo
42; 0b1010; 0o52; 0x2a; 1_000

Working Example

Example Snippetgo
package main
import "fmt"
func main() {  fmt.Println(42, 0b1010, 0o52, 0x2a, 1_000)}
Go Reference