Reduce sets d to x with all trailing zeros removed and returns the number of zeros removed.
(d, x *Decimal)
| 1275 | // Reduce sets d to x with all trailing zeros removed and returns the number |
| 1276 | // of zeros removed. |
| 1277 | func (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. |