Abs returns the absolute value of the decimal.
()
| 511 | |
| 512 | // Abs returns the absolute value of the decimal. |
| 513 | func (d Decimal) Abs() Decimal { |
| 514 | if !d.IsNegative() { |
| 515 | return d |
| 516 | } |
| 517 | d.ensureInitialized() |
| 518 | d2Value := new(big.Int).Abs(d.value) |
| 519 | return Decimal{ |
| 520 | value: d2Value, |
| 521 | exp: d.exp, |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | // Add returns d + d2. |
| 526 | func (d Decimal) Add(d2 Decimal) Decimal { |