[
https://issues.apache.org/jira/browse/ARROW-16223?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Antoine Pitrou resolved ARROW-16223.
------------------------------------
Fix Version/s: 8.0.0
Resolution: Fixed
Issue resolved by pull request 12917
[https://github.com/apache/arrow/pull/12917]
> BasicDecimal128::ReduceScaleBy with rounding works incorrectly
> --------------------------------------------------------------
>
> Key: ARROW-16223
> URL: https://issues.apache.org/jira/browse/ARROW-16223
> Project: Apache Arrow
> Issue Type: Bug
> Components: C++
> Reporter: Renat Valiullin
> Assignee: Yibo Cai
> Priority: Major
> Labels: pull-request-available
> Fix For: 8.0.0
>
> Time Spent: 50m
> Remaining Estimate: 0h
>
> {code:java}
> BasicDecimal128 one(5); // 0.5
> one.ReduceScaleBy(1, true); // expected 1, but result is -1 {code}
> {code:java}
> BasicDecimal128 BasicDecimal128::ReduceScaleBy(int32_t reduce_by, bool round)
> const {
> ...
> if (remainder.Abs() >= divisor_half) {
> if (result > 0) { // should be >=
> result += 1;
> }
> else {
> result -= 1;
> }
> }
> {code}
>
--
This message was sent by Atlassian Jira
(v8.20.7#820007)