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

Function DecodeFloatAscending

pkg/util/encoding/float.go:61–86  ·  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

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

Callers 4

DecodeBox2DAscendingFunction · 0.85
prettyPrintFirstValueFunction · 0.85
DecodeUntaggedBox2DValueFunction · 0.85
DecodeFloatDescendingFunction · 0.85

Calls 3

PeekTypeFunction · 0.85
DecodeUint64AscendingFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…