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

Function DecodeFloatAscending

pkg/util/encoding/float.go:66–91  ·  view source on GitHub ↗

DecodeFloatAscending returns the remaining byte slice after decoding and the decoded float64 from buf.

(buf []byte)

Source from the content-addressed store, hash-verified

64// DecodeFloatAscending returns the remaining byte slice after decoding and the decoded
65// float64 from buf.
66func DecodeFloatAscending(buf []byte) ([]byte, float64, error) {
67 if PeekType(buf) != Float {
68 return buf, 0, errors.Errorf("did not find marker")
69 }
70 switch buf[0] {
71 case floatNaN, floatNaNDesc:
72 return buf[1:], math.NaN(), nil
73 case floatNeg:
74 b, u, err := DecodeUint64Ascending(buf[1:])
75 if err != nil {
76 return b, 0, err
77 }
78 u = ^u
79 return b, math.Float64frombits(u), nil
80 case floatZero:
81 return buf[1:], 0, nil
82 case floatPos:
83 b, u, err := DecodeUint64Ascending(buf[1:])
84 if err != nil {
85 return b, 0, err
86 }
87 return b, math.Float64frombits(u), nil
88 default:
89 return nil, 0, errors.Errorf("unknown prefix of the encoded byte slice: %q", buf)
90 }
91}
92
93// DecodeFloatDescending decodes floats encoded with EncodeFloatDescending.
94func DecodeFloatDescending(buf []byte) ([]byte, float64, error) {

Callers 2

prettyPrintFirstValueFunction · 0.85
DecodeFloatDescendingFunction · 0.85

Calls 2

PeekTypeFunction · 0.85
DecodeUint64AscendingFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…