Fix ROUND_TO_AWAY rounding decision in float_bvt#8983
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes the ROUND_TO_AWAY (round-to-nearest, ties away from zero) rounding increment decision in the float_bvt encoding to match IEEE-754 semantics and float_utilst, and adds a regression test for both SAT (--floatbv) and SMT2/Z3 paths.
Changes:
- Correct
float_bvt::fraction_rounding_decisionforROUND_TO_AWAYto use onlyrounding_bit(notrounding_bit || sticky_bit). - Add a new regression test
Float-round-to-awaycovering tie and non-tie cases. - Add an SMT2/Z3 regression descriptor to exercise the SMT path.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/solvers/floatbv/float_bv.cpp | Fixes the rounding increment condition for ROUND_TO_AWAY in the floatbv encoding. |
| regression/cbmc/Float-round-to-away/main.c | Adds a targeted regression program for ROUND_TO_AWAY tie/non-tie behavior. |
| regression/cbmc/Float-round-to-away/test.desc | Runs the regression with --floatbv (SAT/bit-vector path). |
| regression/cbmc/Float-round-to-away/test_smt.desc | Runs the regression with --smt2 --z3 (SMT path). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8983 +/- ##
===========================================
+ Coverage 80.59% 80.63% +0.04%
===========================================
Files 1713 1713
Lines 189403 189403
Branches 73 73
===========================================
+ Hits 152647 152732 +85
+ Misses 36756 36671 -85 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
3e0b040 to
d5b9a51
Compare
d5b9a51 to
8373cb6
Compare
float_bvt::fraction_rounding_decision used or_exprt(rounding_bit, sticky_bit) for ROUND_TO_AWAY, which incorrectly rounds away from zero whenever any extra bits are non-zero. The correct formula is just rounding_bit, matching float_utilst. ROUND_TO_AWAY means 'round to nearest, ties away from zero': - rounding_bit=0: closer to truncated value, don't increment - rounding_bit=1, sticky=0: exact tie, round away (increment) - rounding_bit=1, sticky=1: closer to incremented value, increment The regression test exercises this via the --smt2 path, which lowers floating-point operations through float_bvt (smt2_convt::convert uses float_bv()); the --floatbv (SAT) path goes through float_utilst, which was already correct, and serves as a sanity check. Test 1 (non-tie sum with rounding_bit=0, sticky=1) fails on the SMT path without this fix. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
8373cb6 to
136b9eb
Compare
kroening
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
float_bvt::fraction_rounding_decision used
or_exprt(rounding_bit, sticky_bit)
for ROUND_TO_AWAY, which incorrectly rounds away from zero whenever any extra bits are non-zero. The correct formula is just rounding_bit, matching float_utilst.
ROUND_TO_AWAY means 'round to nearest, ties away from zero':