MCPcopy Create free account
hub / github.com/cockroachdb/apd / Compose

Method Compose

decomposer.go:94–115  ·  view source on GitHub ↗

Compose sets the internal decimal value from parts. If the value cannot be represented then an error should be returned.

(form byte, negative bool, coefficient []byte, exponent int32)

Source from the content-addressed store, hash-verified

92// Compose sets the internal decimal value from parts. If the value cannot be
93// represented then an error should be returned.
94func (d *Decimal) Compose(form byte, negative bool, coefficient []byte, exponent int32) error {
95 switch form {
96 default:
97 return fmt.Errorf("unknown form: %v", form)
98 case 0:
99 d.Form = Finite
100 // Set rest of finite form below.
101 case 1:
102 d.Form = Infinite
103 d.Negative = negative
104 return nil
105 case 2:
106 d.Form = NaN
107 d.Negative = negative
108 return nil
109 }
110 // Finite form.
111 d.Negative = negative
112 d.Coeff.SetBytes(coefficient)
113 d.Exponent = exponent
114 return nil
115}

Callers 1

TestDecomposerRoundTripFunction · 0.95

Calls 1

SetBytesMethod · 0.80

Tested by 1

TestDecomposerRoundTripFunction · 0.76