Skip to content

GH-55393: [C++][Compute] Fix precision and ties in floating round - #55470

Open
Ayush-CS-89112521 wants to merge 1 commit into
apache:mainfrom
Ayush-CS-89112521:fix-gh-55393-floating-round-precision
Open

Ayush-CS-89112521 wants to merge 1 commit into
apache:mainfrom
Ayush-CS-89112521:fix-gh-55393-floating-round-precision

Conversation

@Ayush-CS-89112521

@Ayush-CS-89112521 Ayush-CS-89112521 commented Nov 10, 2026 •

Copy link
Copy Markdown

Rationale for this change

RoundUtil::Pow10 used float-suffixed constants (1e0F..1e15F), causing double scale factors to truncate to float32 precision and produce off-grid rounded values. In addition, computing fractional parts via round_val - std::floor(round_val) caused catastrophic cancellation on negative numbers near halfway points, triggering false ties.

What changes are included in this PR?

  • Replaced float-suffixed constants in Pow10 with type T constants (T(1e0)..T(1e15)).
  • Replaced std::floor with std::abs(round_val - std::trunc(round_val)) in RoundToMultiple, Round, and RoundBinary.
  • Added regression tests for scale precision, negative halfway ties, and signed zeros.

Are these changes tested?

Yes, added unit tests in scalar_round_arithmetic_test.cc.

Are there any user-facing changes?

Just a bugfix.

Was AI used for this PR?

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

Copilot AI balanced review requested due to automatic review settings November 10, 2026 08:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #55393 has been automatically assigned in GitHub to PR creator.

@Reranko05

Copy link
Copy Markdown
Collaborator

@Ayush-CS-89112521 Could you follow the Arrow PR template and add AI disclosure checkbox in the PR desc. Thanks!

@Ayush-CS-89112521

Copy link
Copy Markdown
Author

Thanks for pointing that out, @Reranko05! Updated the PR description with the AI disclosure section.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #55393 has been automatically assigned in GitHub to PR creator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants