import (
"encoding/binary"
"math"
)
//Float64ToByte Float64转byte
func Float64ToByte(float float64) []byte {
bits := math.Float64bits(float)
bytes := make([]byte, 8)
binary.LittleEndian.PutUint64(bytes, bits)
return bytes
}
//ByteToFloat64 byte转Float64
func ByteToFloat64(bytes []byte) float64 {
bits := binary.LittleEndian.Uint64(bytes)
return math.Float64frombits(bits)
}
有疑问加站长微信联系(非本文作者)