-
Notifications
You must be signed in to change notification settings - Fork 269
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
Introduce floatbv_round_to_integral_exprt
#8538
base: develop
Are you sure you want to change the base?
Conversation
84b83ec
to
b52d32e
Compare
round_to_integral_exprt
floatbv_round_to_integral_exprt
9c6589a
to
e189f1c
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8538 +/- ##
===========================================
- Coverage 78.79% 78.19% -0.61%
===========================================
Files 1730 1730
Lines 199160 201007 +1847
Branches 18320 18331 +11
===========================================
+ Hits 156938 157179 +241
- Misses 42222 43828 +1606 ☔ View full report in Codecov by Sentry. |
f59ad70
to
151d627
Compare
double ceil(double x) | ||
{ | ||
return __sort_of_CPROVER_round_to_integral(FE_UPWARD, x); | ||
return __CPROVER_round_to_integrald(x, 2); // FE_UPWARD |
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.
Why did you choose not to use the named constant FE_UPWARD
?
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.
__CPROVER_round_to_integrald
uses our own numbering, which may or may not match FE_UPWARD
on the target platform.
@@ -136,6 +136,32 @@ bvt float_utilst::to_integer( | |||
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
643372e
to
ce96ec2
Compare
This splits ieee_floatt into two parts: 1) ieee_float_valuet stores an IEEE 754 floating-point value. It offers no operations that require rounding, and hence, does not require a rounding mode. 2) ieee_floatt extends ieee_float_valuet with a rounding mode, and hence, offers operators that require rounding.
dcf0732
to
b6b25aa
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.
b6b25aa
to
ddeedbc
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.