Float32frombits()
function is used to find the floating point number corresponding to the IEEE 754 binary representation x
for the given input (x
– parameter) in Go language. The standard math package of Go programming language has Float32frombits()
function.
Syntax of Float32frombits()
Function in Go Programming
The syntax of
Float32frombits()
function in Go Language is:
func Float32frombits(x uint32) float32
Note: float32
is the set of all IEEE-754 32-bit floating-point numbers and uint32
is the set of all unsigned 32-bit integers. With the range of 0
through 4294967295
.
Parameters of Float32frombits()
Function in Go Programming
x
– Where x
is any Valid float32
Input value. This parameter is required.
Error Handling
If the
If there is no argument (
x
parameter is not a number (numeric value) Float32frombits()
function returns an error
.If there is no argument (
x
– input value) passes to the function, then the compiler will produce an error
.
Return Value of Float32frombits()
Function in Go Programming
Float32frombits()
function will return the floating point number corresponding to the IEEE 754 binary representation of the given input(x
– parameter).
GoLang Float32frombits()
Function Example 1
package main import "fmt" import "math" func main() { var x float32 x = math.Float32frombits(3) fmt.Println(x) }
Output:
4e-45
GoLang Float32frombits()
Function Example 2
package main import "fmt" import "math" func main() { var x float32 x = math.Float32frombits(89) fmt.Println(x) }
Output:
1.25e-43
GoLang Float32frombits()
Function Example 3
package main import "fmt" import "math" func main() { var x float32 x = math.Float32frombits(4294967295) fmt.Println(x) }
Output:
NaN