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

Method validateFlags

quantizedfloat.go:29–65  ·  view source on GitHub ↗

Validates / recomputes decoder flags

()

Source from the content-addressed store, hash-verified

27
28// Validates / recomputes decoder flags
29func (qfd *quantizedFloatDecoder) validateFlags() {
30 // Check that we have some flags set
31 if qfd.Flags == 0 {
32 return
33 }
34
35 // Discard zero flag when encoding min / max set to 0
36 if (qfd.Low == 0.0 && (qfd.Flags&qff_rounddown) != 0) || (qfd.High == 0.0 && (qfd.Flags&qff_roundup) != 0) {
37 qfd.Flags &= ^qff_encode_zero
38 }
39
40 // If min / max is zero when encoding zero, switch to round up / round down instead
41 if qfd.Low == 0.0 && (qfd.Flags&qff_encode_zero) != 0 {
42 qfd.Flags |= qff_rounddown
43 qfd.Flags &= ^qff_encode_zero
44 }
45
46 if qfd.High == 0.0 && (qfd.Flags&qff_encode_zero) != 0 {
47 qfd.Flags |= qff_roundup
48 qfd.Flags &= ^qff_encode_zero
49 }
50
51 // Check if the range spans zero
52 if qfd.Low > 0.0 || qfd.High < 0.0 {
53 qfd.Flags &= ^qff_encode_zero
54 }
55
56 // If we are left with encode zero, only leave integer flag
57 if (qfd.Flags & qff_encode_integers) != 0 {
58 qfd.Flags &= ^(qff_roundup | qff_rounddown | qff_encode_zero)
59 }
60
61 // Verify that we don;t have roundup / rounddown set
62 if qfd.Flags&(qff_rounddown|qff_roundup) == (qff_rounddown | qff_roundup) {
63 _panicf("Roundup / Rounddown are mutually exclusive")
64 }
65}
66
67// Assign multipliers
68func (qfd *quantizedFloatDecoder) assignMultipliers(steps uint32) {

Callers 1

newQuantizedFloatDecoderFunction · 0.95

Calls 1

_panicfFunction · 0.85

Tested by

no test coverage detected