-
Notifications
You must be signed in to change notification settings - Fork 98
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
Audit for truncf*
#1250
Audit for truncf*
#1250
Conversation
let trunc_res = unsafe { std::intrinsics::truncf32(x) }; | ||
|
||
// The expected result is the number minus its fractional part | ||
let expected_res = x - x.fract(); |
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.
Does fract
use trunc
under the hood?
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.
Yes.
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.
Is that a problem for the test, if it's just running (x - f) == (x - f)
?
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.
Yes, it's probably better to avoid it altogether.
It's quite hard to test these functions with symbolic values. Because of that, I've broken the truncf32
test into a three harnesses: One that tests a property for all values and two other for concrete values.
Please let me know what you think! Any suggestions on other tests are welcome.
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.
I'm not sure how to do better either, so LGTM
Can you test |
Thanks @danielsn , this is now testing that property and a few more concrete cases. |
Description of changes:
Restores and completes the audit for the
truncf32
(truncf
) andtruncf64
(trunc
) intrinsics.Resolved issues:
Part of #1163
Part of #1025
Call-outs:
Testing:
How is this change tested? Adds 2 tests.
Is this a refactor change? No.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.