| 676 | } |
| 677 | |
| 678 | BasicDecimal128 Truncate(const BasicDecimalScalar128& x, int32_t out_precision, |
| 679 | int32_t out_scale, int32_t rounding_scale, bool* overflow) { |
| 680 | // no-op if target scale is same as arg scale |
| 681 | if (x.scale() == out_scale && rounding_scale >= 0) { |
| 682 | return x.value(); |
| 683 | } |
| 684 | |
| 685 | if (rounding_scale < 0) { |
| 686 | return RoundWithNegativeScale(x, out_precision, rounding_scale, |
| 687 | RoundType::kRoundTypeTrunc, overflow); |
| 688 | } else { |
| 689 | return RoundWithPositiveScale(x, out_precision, rounding_scale, |
| 690 | RoundType::kRoundTypeTrunc, overflow); |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | BasicDecimal128 Ceil(const BasicDecimalScalar128& x, bool* overflow) { |
| 695 | return RoundWithPositiveScale(x, x.precision(), 0, RoundType::kRoundTypeCeil, overflow); |