MCPcopy Create free account
hub / github.com/dotabuff/manta / quantize

Method quantize

quantizedfloat.go:110–127  ·  view source on GitHub ↗

Quantize a float

(val float32)

Source from the content-addressed store, hash-verified

108
109// Quantize a float
110func (qfd *quantizedFloatDecoder) quantize(val float32) float32 {
111 if val < qfd.Low {
112 if (qfd.Flags & qff_roundup) == 0 {
113 _panicf("Field tried to quantize an out of range value")
114 }
115
116 return qfd.Low
117 } else if val > qfd.High {
118 if (qfd.Flags & qff_rounddown) == 0 {
119 _panicf("Field tried to quantize an out of range value")
120 }
121
122 return qfd.High
123 }
124
125 i := uint32((val - qfd.Low) * qfd.HighLowMul)
126 return qfd.Low + (qfd.High-qfd.Low)*(float32(i)*qfd.DecMul)
127}
128
129// Actual float decoding
130func (qfd *quantizedFloatDecoder) decode(r *reader) float32 {

Callers 1

newQuantizedFloatDecoderFunction · 0.95

Calls 1

_panicfFunction · 0.85

Tested by

no test coverage detected