RoundCeil rounds the decimal towards +infinity. Example: NewFromFloat(545).RoundCeil(-2).String() // output: "600" NewFromFloat(500).RoundCeil(-2).String() // output: "500" NewFromFloat(1.1001).RoundCeil(2).String() // output: "1.11" NewFromFloat(-1.454).RoundCeil(1).String() // output: "-
(places int32)
| 1553 | // NewFromFloat(1.1001).RoundCeil(2).String() // output: "1.11" |
| 1554 | // NewFromFloat(-1.454).RoundCeil(1).String() // output: "-1.4" |
| 1555 | func (d Decimal) RoundCeil(places int32) Decimal { |
| 1556 | if d.exp >= -places { |
| 1557 | return d |
| 1558 | } |
| 1559 | |
| 1560 | rescaled := d.rescale(-places) |
| 1561 | if d.Equal(rescaled) { |
| 1562 | return d |
| 1563 | } |
| 1564 | |
| 1565 | if d.value.Sign() > 0 { |
| 1566 | rescaled.value.Add(rescaled.value, oneInt) |
| 1567 | } |
| 1568 | |
| 1569 | return rescaled |
| 1570 | } |
| 1571 | |
| 1572 | // RoundFloor rounds the decimal towards -infinity. |
| 1573 | // |