Q:

Golang program to find the IEEE 754 representation using math.Float64bits() function of given number

belongs to collection: Golang Basic Programs

0

In this program, we will use math.Float64bits() function. The math.Float64bits() function is used to find the IEEE 754 representation of the given number.

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program/Source Code:

The source code to demonstrate the Float64bits() function is given below. The given program is compiled and executed successfully.

// Golang program to demonstrate
// the Float64bits() function

package main

import (
	"fmt"
	"math"
)

func main() {
	out1 := math.Float64bits(0)
	out2 := math.Float64bits(1)
	out3 := math.Float64bits(2)
	out4 := math.Float64bits(2.5)

	fmt.Println(out1)
	fmt.Println(out2)
	fmt.Println(out3)
	fmt.Println(out4)
}

Output:

0
4607182418800017408
4611686018427387904
4612811918334230528

Explanation:

In the above program, we declare the package main. The main package is used to tell the Go language compiler that the package must be compiled and produced the executable file. Here, we imported the fmt package that includes the files of package fmt then we can use a function related to the fmt package.

In the main() function, we find the IEEE 754 representation of given numbers and print on the console screen.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Golang Basic Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Golang program to check given number is EVEN or OD... >>
<< Golang program to find the remainder for floating-...