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

Method setAsNaN

context.go:107–129  ·  view source on GitHub ↗

setAsNaN sets d to the first NaNSignaling, or otherwise first NaN, of x and y. x is required, y is optional. Expects one of the two inputs to be NaN.

(d *Decimal, x, y *Decimal)

Source from the content-addressed store, hash-verified

105// x and y. x is required, y is optional. Expects one of the two inputs
106// to be NaN.
107func (c *Context) setAsNaN(d *Decimal, x, y *Decimal) (Condition, error) {
108 var nan *Decimal
109 // Per the method contract, NaNSignaling takes precedence over NaN.
110 if x.Form == NaNSignaling {
111 nan = x
112 } else if y != nil && y.Form == NaNSignaling {
113 nan = y
114 } else if x.Form == NaN {
115 nan = x
116 } else if y != nil && y.Form == NaN {
117 nan = y
118 } else {
119 return 0, errors.New("no NaN value found; was shouldSetAsNaN called?")
120 }
121 d.Set(nan)
122 var res Condition
123 if nan.Form == NaNSignaling {
124 res = InvalidOperation
125 d.Form = NaN
126 }
127 _, err := c.goError(res)
128 return res, err
129}
130
131func (c *Context) add(d, x, y *Decimal, subtract bool) (Condition, error) {
132 if c.shouldSetAsNaN(x, y) {

Callers 14

addMethod · 0.95
AbsMethod · 0.95
NegMethod · 0.95
MulMethod · 0.95
quoSpecialsMethod · 0.95
RemMethod · 0.95
rootSpecialsMethod · 0.95
logSpecialsMethod · 0.95
ExpMethod · 0.95
PowMethod · 0.95
QuantizeMethod · 0.95
toIntegralSpecialsMethod · 0.95

Calls 2

goErrorMethod · 0.95
SetMethod · 0.45

Tested by

no test coverage detected