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

Method Reduce

context.go:1277–1288  ·  view source on GitHub ↗

Reduce sets d to x with all trailing zeros removed and returns the number of zeros removed.

(d, x *Decimal)

Source from the content-addressed store, hash-verified

1275// Reduce sets d to x with all trailing zeros removed and returns the number
1276// of zeros removed.
1277func (c *Context) Reduce(d, x *Decimal) (int, Condition, error) {
1278 if c.shouldSetAsNaN(x, nil) {
1279 res, err := c.setAsNaN(d, x, nil)
1280 return 0, res, err
1281 }
1282 neg := x.Negative
1283 _, n := d.Reduce(x)
1284 d.Negative = neg
1285 res := c.round(d, d)
1286 res, err := c.goError(res)
1287 return n, res, err
1288}
1289
1290// exp10 returns x, 10^x. An error is returned if x is too large.
1291// The returned value must not be mutated.

Callers 2

RunMethod · 0.45
TestReduceFunction · 0.45

Calls 4

shouldSetAsNaNMethod · 0.95
setAsNaNMethod · 0.95
roundMethod · 0.95
goErrorMethod · 0.95

Tested by 2

RunMethod · 0.36
TestReduceFunction · 0.36