zeroshade commented on code in PR #43957:
URL: https://github.com/apache/arrow/pull/43957#discussion_r1767195342


##########
cpp/src/arrow/util/decimal.cc:
##########
@@ -156,7 +162,9 @@ struct DecimalRealConversion : public 
BaseDecimalRealConversion {
         // NOTE: if `precision` is the full precision then the algorithm will
         // lose the last digit. If `precision` is almost the full precision,
         // there can be an off-by-one error due to rounding.
-        const int mul_step = std::max(1, kMaxPrecision - precision);
+        constexpr int is_dec32_or_dec64 =
+            DecimalType::kByteWidth <= BasicDecimal64::kByteWidth;
+        const int mul_step = std::max(1, kMaxPrecision - precision - 
is_dec32_or_dec64);

Review Comment:
   I've adjusted the tests to simply not hit this case anymore with the 
off-by-one rounding issue for decimal64. 
   
   Let me know if you prefer that to the above hack with explanation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to