I want to convert a float64 number into int64 number. That is, I want to read the binary contents of the float64 register as if it is a int64 value. I mean, I want the go equivalent of the following C code
long y;
float x = 1.2;
y = * ( long * ) &x;
How do I do that?
Here is my try which is not working.
package main
import (
"fmt"
)
func main() {
x := float64(1.2)
y := *((*int64)(&x))
fmt.Println("Ans: ", y)
}