Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeCompact8 ¶
DecodeCompact8 converts a Compact8 value to an int64.
Types ¶
type Compact8 ¶
type Compact8 = uint8
Compact8 is an unsigned 8-bit compact integer encoding with 12 mantissa values per exponent level (instead of the standard power-of-2 split).
For a byte value b, let e = b / 12 and m = b % 12:
b=0: 0 (zero) e=0, m>=1: m << (offset+1) (subnormal) e>=1: (12+m) << (e+offset) (normalized)
This gives approximately 8.3% relative precision (12 values per octave) and a representable range from 32 to 503316480 with offset 4.
func EncodeCompact8 ¶
EncodeCompact8 encodes a non-negative int64 into Compact8 representation. The value is rounded down to the nearest representable value. Negative values go to 0 and values above the maximum representable go to 255.
func UpdateCompact8 ¶
UpdateCompact8 returns the Compact8 encoding of value, but with hysteresis: it sticks to prev unless the new code is significantly closer. This prevents oscillation when the underlying value fluctuates near a bucket boundary.
type Number ¶
type Number struct {
// contains filtered or unexported fields
}