gitee.com/quant1x/num@v0.3.2/math32/unsafe.go (about)

     1  package math32
     2  
     3  import "unsafe"
     4  
     5  // Float32bits returns the IEEE 754 binary representation of f.
     6  func Float32bits(f float32) uint32 { return *(*uint32)(unsafe.Pointer(&f)) }
     7  
     8  // Float32frombits returns the floating point number corresponding
     9  // to the IEEE 754 binary representation b.
    10  func Float32frombits(b uint32) float32 { return *(*float32)(unsafe.Pointer(&b)) }
    11  
    12  // Float64bits returns the IEEE 754 binary representation of f.
    13  func Float64bits(f float64) uint64 { return *(*uint64)(unsafe.Pointer(&f)) }
    14  
    15  // Float64frombits returns the floating point number corresponding
    16  // the IEEE 754 binary representation b.
    17  func Float64frombits(b uint64) float64 { return *(*float64)(unsafe.Pointer(&b)) }
    18  
    19  func float32ibits(f float32) int32 { return *(*int32)(unsafe.Pointer(&f)) }
    20  
    21  func float32fromibits(b int32) float32 { return *(*float32)(unsafe.Pointer(&b)) }