You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Yibo Cai (Jira)" <ji...@apache.org> on 2022/04/19 02:01:00 UTC

[jira] [Commented] (ARROW-16223) BasicDecimal128::ReduceScaleBy with rounding works incorrectly

    [ https://issues.apache.org/jira/browse/ARROW-16223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17523986#comment-17523986 ] 

Yibo Cai commented on ARROW-16223:
----------------------------------

Thanks for the report. Will you open a PR?

> 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
>            Priority: Major
>
> {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.1#820001)