| 660 | } |
| 661 | |
| 662 | BasicDecimal128 Round(const BasicDecimalScalar128& x, int32_t out_precision, |
| 663 | int32_t out_scale, int32_t rounding_scale, bool* overflow) { |
| 664 | // no-op if target scale is same as arg scale |
| 665 | if (x.scale() == out_scale && rounding_scale >= 0) { |
| 666 | return x.value(); |
| 667 | } |
| 668 | |
| 669 | if (rounding_scale < 0) { |
| 670 | return RoundWithNegativeScale(x, out_precision, rounding_scale, |
| 671 | RoundType::kRoundTypeHalfRoundUp, overflow); |
| 672 | } else { |
| 673 | return RoundWithPositiveScale(x, out_precision, rounding_scale, |
| 674 | RoundType::kRoundTypeHalfRoundUp, overflow); |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | BasicDecimal128 Truncate(const BasicDecimalScalar128& x, int32_t out_precision, |
| 679 | int32_t out_scale, int32_t rounding_scale, bool* overflow) { |