Search⌘ K
AI Features

Puzzle 12 Explanation: Go spec2

Explore Go's number types focusing on integers and floats, and learn how to interpret number literals in scientific and hexadecimal floating-point notation. Understand the Go spec for writing readable number values and calculating their results accurately.

We'll cover the following...

Try it yourself

Try executing the code below to see the result for yourself.

Go (1.16.5)
package main
import (
"fmt"
)
func main() {
fmt.Println(0x1p-2)
}

Explanation

Go has several number types. The two main ones are integers and floats.

Integer

These are whole numbers. Go has int8, int16, int32, int64, and int. There are also all the unsigned ones, such as uint8 and so on. ...