github.com/sandwich-go/boost@v1.3.29/xconv/binary.go (about)

     1  package xconv
     2  
     3  import (
     4  	"encoding/binary"
     5  	"math"
     6  )
     7  
     8  // LittleEndianDecodeToFloat32 bytes to float32 use little-endian
     9  func LittleEndianDecodeToFloat32(b []byte) float32 {
    10  	return math.Float32frombits(binary.LittleEndian.Uint32(LeFillUpSize(b, 4)))
    11  }
    12  
    13  // LittleEndianDecodeToFloat64 bytes to float64 use little-endian
    14  func LittleEndianDecodeToFloat64(b []byte) float64 {
    15  	return math.Float64frombits(binary.LittleEndian.Uint64(LeFillUpSize(b, 8)))
    16  }
    17  
    18  // LittleEndianDecodeToInt64 bytes to int64 use little-endian
    19  func LittleEndianDecodeToInt64(b []byte) int64 {
    20  	return int64(binary.LittleEndian.Uint64(LeFillUpSize(b, 8)))
    21  }
    22  
    23  // LittleEndianDecodeToUint64 bytes to uint64 use little-endian
    24  func LittleEndianDecodeToUint64(b []byte) uint64 {
    25  	return binary.LittleEndian.Uint64(LeFillUpSize(b, 8))
    26  }