You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think that the method of using pack uint data method to pack float data is wrong, because the head sign of packing float is different from the head sign of packing uint, so I modify code:
// Packs a given value and writes it into the specified writer.
func PackFloat32(writer io.Writer, value float32) (n int, err error) {
valueToUint32 := _(_uint32)(unsafe.Pointer(&value))
return writer.Write([]byte{0xca, byte(valueToUint32 >> 24), byte(valueToUint32 >> 16), byte(valueToUint32 >> 8), byte(valueToUint32)})
}
// Packs a given value and writes it into the specified writer.
func PackFloat64(writer io.Writer, value float64) (n int, err error) {
valueToUint64 := _(_uint64)(unsafe.Pointer(&value))
return writer.Write([]byte{0xcb, byte(valueToUint64 >> 56), byte(valueToUint64 >> 48), byte(valueToUint64 >> 40), byte(valueToUint64 >> 32), byte(valueToUint64 >> 24), byte(valueToUint64 >> 16), byte(valueToUint64 >> 8), byte(valueToUint64)})
}
The text was updated successfully, but these errors were encountered:
I think that the method of using pack uint data method to pack float data is wrong, because the head sign of packing float is different from the head sign of packing uint, so I modify code:
// Packs a given value and writes it into the specified writer.
func PackFloat32(writer io.Writer, value float32) (n int, err error) {
valueToUint32 := _(_uint32)(unsafe.Pointer(&value))
return writer.Write([]byte{0xca, byte(valueToUint32 >> 24), byte(valueToUint32 >> 16), byte(valueToUint32 >> 8), byte(valueToUint32)})
}
// Packs a given value and writes it into the specified writer.
func PackFloat64(writer io.Writer, value float64) (n int, err error) {
valueToUint64 := _(_uint64)(unsafe.Pointer(&value))
return writer.Write([]byte{0xcb, byte(valueToUint64 >> 56), byte(valueToUint64 >> 48), byte(valueToUint64 >> 40), byte(valueToUint64 >> 32), byte(valueToUint64 >> 24), byte(valueToUint64 >> 16), byte(valueToUint64 >> 8), byte(valueToUint64)})
}
The text was updated successfully, but these errors were encountered: