out = {c: d1.c, q: 10^max(d1.q - d2.q, 0)}
(d1, d2 *Decimal, gas *uint64)
| 375 | |
| 376 | // out = {c: d1.c, q: 10^max(d1.q - d2.q, 0)} |
| 377 | func add_helper(d1, d2 *Decimal, gas *uint64) (out int256) { |
| 378 | var exponent_diff int256 |
| 379 | Sub(&d1.q, &d2.q, &exponent_diff, gas) |
| 380 | if Sign(&exponent_diff, gas) == -1 { |
| 381 | exponent_diff = *ZERO_INT256 // shallow copy ok |
| 382 | } |
| 383 | |
| 384 | Exp(TEN_INT256, &exponent_diff, &out, gas) |
| 385 | Mul(&d1.c, &out, &out, gas) |
| 386 | |
| 387 | return out |
| 388 | } |
| 389 | |
| 390 | // remove trailing zeros from coefficient |
| 391 | func find_num_trailing_zeros_signed_DECIMAL256(a *int256, gas *uint64) (p, ten_power *int256) { |