MCPcopy Create free account
hub / github.com/apache/arrow / Truncate

Function Truncate

cpp/src/gandiva/precompiled/decimal_ops.cc:678–692  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

676}
677
678BasicDecimal128 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
694BasicDecimal128 Ceil(const BasicDecimalScalar128& x, bool* overflow) {
695 return RoundWithPositiveScale(x, x.precision(), 0, RoundType::kRoundTypeCeil, overflow);

Callers 4

TEST_FFunction · 0.85
truncate_decimal128Function · 0.85
truncate_int64_int32Function · 0.85

Calls 4

RoundWithNegativeScaleFunction · 0.85
RoundWithPositiveScaleFunction · 0.85
scaleMethod · 0.45
valueMethod · 0.45

Tested by 1

TEST_FFunction · 0.68