Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-16223

BasicDecimal128::ReduceScaleBy with rounding works incorrectly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 8.0.0
    • C++

    Description

      BasicDecimal128 one(5); // 0.5
      one.ReduceScaleBy(1, true); // expected 1, but result is -1 
      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;
          } 
        }
      

       

      Attachments

        Issue Links

          Activity

            People

              yibocai Yibo Cai
              rip.nsk@gmail.com Renat Valiullin
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h