MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / EncodeFloatAscending

Function EncodeFloatAscending

pkg/util/encoding/float.go:36–54  ·  view source on GitHub ↗

EncodeFloatAscending returns the resulting byte slice with the encoded float64 appended to b. The encoded format for a float64 value f is, for positive f, the encoding of the 64 bits (in IEEE 754 format) re-interpreted as an int64 and encoded using EncodeUint64Ascending. For negative f, we keep the

(b []byte, f float64)

Source from the content-addressed store, hash-verified

34// This ordering ensures that NaNs are always sorted first in either encoding
35// direction, and that after them a logical ordering is followed.
36func EncodeFloatAscending(b []byte, f float64) []byte {
37 // Handle the simplistic cases first.
38 switch {
39 case math.IsNaN(f):
40 return append(b, floatNaN)
41 case f == 0:
42 // This encodes both positive and negative zero the same. Negative zero uses
43 // composite indexes to decode itself correctly.
44 return append(b, floatZero)
45 }
46 u := math.Float64bits(f)
47 if u&(1<<63) != 0 {
48 u = ^u
49 b = append(b, floatNeg)
50 } else {
51 b = append(b, floatPos)
52 }
53 return EncodeUint64Ascending(b, u)
54}
55
56// EncodeFloatDescending is the descending version of EncodeFloatAscending.
57func EncodeFloatDescending(b []byte, f float64) []byte {

Callers 1

EncodeFloatDescendingFunction · 0.85

Calls 1

EncodeUint64AscendingFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…