unsafe.go 861 B

123456789101112131415161718192021
  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)) }
  13. func float32ibits(f float32) int32 { return *(*int32)(unsafe.Pointer(&f)) }
  14. func float32fromibits(b int32) float32 { return *(*float32)(unsafe.Pointer(&b)) }