Math package for float32 / compex64 types https://godoc.org/pkg/math/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

unsafe.go 701B

1234567891011121314151617
  1. package math32
  2. import "unsafe"
  3. // Float32bits returns the IEEE 754 binary representation of f.
  4. func Float32bits(f float32) uint32 { return *(*uint32)(unsafe.Pointer(&f)) }
  5. // Float32frombits returns the floating point number corresponding
  6. // to the IEEE 754 binary representation b.
  7. func Float32frombits(b uint32) float32 { return *(*float32)(unsafe.Pointer(&b)) }
  8. // Float64bits returns the IEEE 754 binary representation of f.
  9. func Float64bits(f float64) uint64 { return *(*uint64)(unsafe.Pointer(&f)) }
  10. // Float64frombits returns the floating point number corresponding
  11. // the IEEE 754 binary representation b.
  12. func Float64frombits(b uint64) float64 { return *(*float64)(unsafe.Pointer(&b)) }