MCPcopy Create free account
hub / github.com/dolthub/doltgresql / Float32

Method Float32

utils/writer.go:108–117  ·  view source on GitHub ↗

Float32 writes a float32.

(val float32)

Source from the content-addressed store, hash-verified

106
107// Float32 writes a float32.
108func (writer *Writer) Float32(val float32) {
109 // Float encoding produces byte-comparable serialized values when looking at the exponent and mantissa. This means
110 // that we just have to flip to exponent and mantissa for negative values, and flip the sign bit so that negatives
111 // sort before positives. To do this, we take advantage of arithmetic shifting by casting to a signed integer to
112 // create a mask that only exists for negative values.
113 uval := math.Float32bits(val)
114 uval ^= uint32(int32(uval)>>31) & 0x7FFFFFFF
115 uval ^= 0x80000000
116 writer.Uint32(uval)
117}
118
119// Float64 writes a float64.
120func (writer *Writer) Float64(val float64) {

Callers 4

TestWriterReaderFunction · 0.95
TestWriterOrderFunction · 0.95
Float32SliceMethod · 0.95
SerializeMethod · 0.95

Calls 1

Uint32Method · 0.95

Tested by 2

TestWriterReaderFunction · 0.76
TestWriterOrderFunction · 0.76