-
Notifications
You must be signed in to change notification settings - Fork 283
Introduce floatbv_round_to_integral_exprt
#8538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
84b83ec to
b52d32e
Compare
round_to_integral_exprtfloatbv_round_to_integral_exprt
9c6589a to
e189f1c
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8538 +/- ##
===========================================
+ Coverage 79.60% 79.63% +0.02%
===========================================
Files 1733 1733
Lines 197377 197686 +309
Branches 18169 18226 +57
===========================================
+ Hits 157118 157418 +300
- Misses 40259 40268 +9 ☔ View full report in Codecov by Sentry. |
f59ad70 to
151d627
Compare
| return result; | ||
| } | ||
|
|
||
| bvt float_utilst::round_to_integral(const bvt &src) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does this actually consider the rounding mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It calls add_sub.
|
|
||
| auto tmp1 = add_sub(src, magic_number_bv, false); | ||
|
|
||
| auto tmp2 = add_sub(tmp1, magic_number_bv, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If ieee_floatt::round_to_integral is to be trusted, shouldn't the sign bit be used instead of hard-coding false and true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note line 153 -- this variant tweaks the sign bit of the magic constant instead.
ec1cfc6 to
643372e
Compare
b6b25aa to
ddeedbc
Compare
ddeedbc to
8b80200
Compare
remi-delmas-3000
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good but could use some comments to explain how fractional bits get cleared due to the exponent alignment with the magic constant, and tests for halfway values and different tie breaking modes
90018fc to
5e40ab0
Compare
7f1be0e to
a6d1ba4
Compare
|
|
||
| magic_number_bv.back() = src.back(); // copy sign bit | ||
|
|
||
| auto tmp1 = add_sub(src, magic_number_bv, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this overflow when the number of exponent bits is small?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, ge_magic_number will be true.
a6d1ba4 to
6c7c09e
Compare
This adds a new expression, floatbv_round_to_integral, which rounds an IEEE 754 floating-point number given as bit-vector to the nearest integer, considering the explicitly given rounding mode.
6c7c09e to
49850ea
Compare
This fixes the rounding modes used for the floor and trunc C library functions.
This fixes the rounding modes used for the floor and trunc C library functions.
This fixes the rounding modes used for the floor and trunc C library functions.
This fixes the rounding modes used for the floor and trunc C library functions.
This fixes the rounding modes used for the floor and trunc C library functions.
This fixes the rounding modes used for the floor and trunc C library functions.
fixup #8538 -- correct rounding modes for `floor`, `trunc`
This release addresses both soundness (via diffblue#8562) and performance issues (via diffblue#8574, diffblue#8576) in our code contracts instrumentation, and includes a collection of bit-operator cleanup (such as diffblue#8524, diffblue#8531) and floating-point support improvements (TiesToAway rounding via diffblue#8515, native rounding to integer via diffblue#8538) that aid EBMC/HW-CBMC.
This adds a new expression,
floatbv_round_to_integral, which rounds an IEEE 754 floating-point number given as bit-vector to the nearest integer, considering the explicitly given rounding mode.