Cookies management by TermsFeed Cookie Consent

📊 The maximum and minimum value of the float types in Go

shorts numbers math

The maximum value of the float64 type in Go is 1.79769313486231570814527423731704356798070e+308 and you can get this value using the math.MaxFloat64 constant.

The minimum value above zero (smallest positive, non-zero value) of the float64 type in Go is 4.9406564584124654417656879286822137236505980e-324 and you can get this value using the math.SmallestNonzeroFloat64 constant.

The maximum value of the float32 type in Go is 3.40282346638528859811704183484516925440e+38 and you can get this value using the math.MaxFloat32 constant.

The minimum value above zero (smallest positive, non-zero value) of the float32 type in Go is 1.401298464324817070923729583289916131280e-45 and you can get this value using the math.SmallestNonzeroFloat32 constant.

package main

import (
    "fmt"
    "math"
)

func main() {
    fmt.Printf("min float64: %.50e\n", math.SmallestNonzeroFloat64)
    fmt.Printf("max float64: %.50e\n", math.MaxFloat64)

    fmt.Printf("min float32: %.50e\n", math.SmallestNonzeroFloat32)
    fmt.Printf("max float32: %.50e\n", math.MaxFloat32)
}

Output:

min float64: 4.94065645841246544176568792868221372365059802614325e-324
max float64: 1.79769313486231570814527423731704356798070567525845e+308
min float32: 1.40129846432481707092372958328991613128026194187652e-45
max float32: 3.40282346638528859811704183484516925440000000000000e+38

Thank you for being on our site 😊. If you like our tutorials and examples, please consider supporting us with a cup of coffee and we'll turn it into more great Go examples.

Have a great day!

Buy Me A Coffee

🧊 Cube root in Go

shorts numbers math

🟦 Square root in Go

shorts numbers math

🍰 The maximum and minimum value of the int types in Go

shorts numbers math