Wednesday, June 26, 2024
HomeGolangThe utmost and minimal worth of the float varieties in Go (Golang)

The utmost and minimal worth of the float varieties in Go (Golang)



The utmost worth of the float64 sort in Go is 1.79769313486231570814527423731704356798070e+308 and you will get this worth utilizing the math.MaxFloat64 fixed.

The minimal worth above zero (smallest optimistic, non-zero worth) of the float64 sort in Go is 4.9406564584124654417656879286822137236505980e-324 and you will get this worth utilizing the math.SmallestNonzeroFloat64 fixed.

The utmost worth of the float32 sort in Go is 3.40282346638528859811704183484516925440e+38 and you will get this worth utilizing the math.MaxFloat32 fixed.

The minimal worth above zero (smallest optimistic, non-zero worth) of the float32 sort in Go is 1.401298464324817070923729583289916131280e-45 and you will get this worth utilizing the math.SmallestNonzeroFloat32 fixed.

bundle primary

import (
    "fmt"
    "math"
)

func primary() {
    fmt.Printf("min float64: %.50en", math.SmallestNonzeroFloat64)
    fmt.Printf("max float64: %.50en", math.MaxFloat64)

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

Output:

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments