From af8c72279cea6c75998a614d7de293fd03f2aa6d Mon Sep 17 00:00:00 2001 From: Matt Topol Date: Mon, 30 Sep 2024 11:11:30 -0400 Subject: [PATCH] make RoundedRightShift a no-op --- cpp/src/arrow/util/decimal.cc | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/cpp/src/arrow/util/decimal.cc b/cpp/src/arrow/util/decimal.cc index c8703d1f2e6f5..7ab3061d4f4e6 100644 --- a/cpp/src/arrow/util/decimal.cc +++ b/cpp/src/arrow/util/decimal.cc @@ -94,7 +94,7 @@ struct DecimalRealConversion : public BaseDecimalRealConversion { constexpr int kMantissaDigits = RealTraits::kMantissaDigits; // to avoid precision and rounding issues, we'll unconditionally - // throw Decimal32 to the approx algorithm instead. (GH-44216) + // throw Decimal32 to the approx algorithm instead. (GH-44216) if constexpr (std::is_base_of_v) { return Derived::FromPositiveRealApprox(real, precision, scale); } @@ -258,29 +258,10 @@ struct Decimal32RealConversion using Base::PowerOfTen; static Decimal32 RoundedRightShift(const Decimal32& x, int bits) { - if (bits == 0) { - return x; - } - - int32_t result = x.value(); - uint32_t shifted = 0; - if (bits > 0) { - shifted = (result << (32 - bits)); - result >>= bits; - } - constexpr uint32_t kHalf = 0x80000000; - if (shifted > kHalf) { - // strictly more than half => round up - result += 1; - } else if (shifted == kHalf) { - // exactly half => round to even - if ((result & 1) != 0) { - result += 1; - } - } else { - // strictly less than half => round down - } - return Decimal32(result); + // currently we *only* push to the Approx method for Decimal32 + // so this should never get called. + DCHECK(false); + return x; } template