Home »
Golang »
Golang Reference
Golang math.MaxFloat32 Constant with Examples
Golang | math.MaxFloat32 Constant: Here, we are going to learn about the MaxFloat32 constant of the math package with its usages, syntax, and examples.
Submitted by IncludeHelp, on August 25, 2021
math.MaxFloat32 Constant
The MaxFloat32 constant is an inbuilt constant of the math package which is used to get the largest finite value of float32 type.
The value of math.MaxFloat32 constants is 3.40282346638528859811704183484516925440e+38 or 0x1p127 * (1 + (1 - 0x1p-23)).
Syntax
float64 math.MaxFloat32
Parameters
Return Value
The return type of math.MaxFloat32 constant is float64, it returns the largest finite value of float32 type.
Example 1
// Golang program to demonstrate the
// example of math.MaxFloat32 Constant
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("Type of math.MaxFloat32 is %T\n", math.MaxFloat32)
fmt.Println("Value of math.MaxFloat32:", math.MaxFloat32)
}
Output:
Type of math.MaxFloat32 is float64
Value of math.MaxFloat32: 3.4028234663852886e+38
Explanation:
In the above program, we imported the math package to use the math.MaxFloat32 constant, then printed the type and value of the math.MaxFloat32 constant.
Example 2
// Golang program to demonstrate the
// example of math.MaxFloat32 Constant
package main
import (
"fmt"
"math"
)
// creating function to
// return the value of MaxFloat32.
func getMaxFloat32() float64 {
return math.MaxFloat32
}
func main() {
fmt.Println("Value of math.MaxFloat32:", getMaxFloat32())
}
Output:
Value of math.MaxFloat32: 3.4028234663852886e+38
Golang math Package Constants and Functions »