Tsallaka zuwa abun ciki
Justice Tech School

Booleans, Integers and Floats

Integer sizes are int8 to int64 and uint8 to uint64, plus int and uint. Floats are float32 and float64. Integer overflow wraps around.

Example
package main

import (
	"fmt"
	"math"
)

func main() {
	var a int8 = 127
	a++
	var u uint8 = 0
	u--
	fmt.Println(a, u, math.MaxInt32)
	fmt.Println(7/2, 7.0/2, math.Sqrt(2) > 1.41)
	fmt.Printf("%.4f\n", math.Pi)
}

Result

-128 255 2147483647
3 3.5 true
3.1416

Exercise

Larger of two numbers.

math.(3, 9)

Quiz Test

What happens when an int8 overflows?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.