-
Notifications
You must be signed in to change notification settings - Fork 39
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
Implement f32/f64 comparison operators #449
Conversation
0b749f0
to
6942142
Compare
3d213ef
to
c2acfb3
Compare
0cf4a4e
to
e4b50c2
Compare
std::nextafter(-Limits::denorm_min(), -Limits::infinity()), | ||
-Limits::denorm_min(), | ||
TypeParam{0}, // FIXME. |
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.
What is the fixme here?
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 was to add "negative zero" comparison.
} | ||
|
||
// Negative zero. |
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 are these needed if we have -0
and 0
in ordered_values
?
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.
We don't.
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.
Ah, its -1 and 0. Can we just have -0 there too?
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.
No.
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?
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?
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.
The values in the array must be strictly ordered, otherwise we don't know what result to expect. But -0 == 0
.
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 don't see why they need to be strictly ordered, to get the expected result you always calculate it as i op j
anyway. Also as at some iterations i < j
, at others j < i
(and at some i == j
)
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.
Please commit a change doing that because I don't see how this suppose to work.
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.
Oh I see, I misunderstood how it works first. But I pushed the way I thought it works first, it doesn't rely on strict ordering, what do you think?
e4b50c2
to
cc8dc5b
Compare
Codecov Report
@@ Coverage Diff @@
## master #449 +/- ##
========================================
Coverage 99.51% 99.52%
========================================
Files 54 54
Lines 15349 15507 +158
========================================
+ Hits 15275 15433 +158
Misses 74 74 |
4935d40
to
d15f8b8
Compare
d15f8b8
to
8b963e4
Compare
68ecdc9
to
3524d8e
Compare
EXPECT_THAT(execute(*inst, gt, {a, b}), Result(uint32_t{i > j})) << a << ">" << b; | ||
EXPECT_THAT(execute(*inst, le, {a, b}), Result(uint32_t{i <= j})) << a << "<=" << b; | ||
EXPECT_THAT(execute(*inst, ge, {a, b}), Result(uint32_t{i >= j})) << a << ">=" << b; | ||
EXPECT_THAT(execute(*inst, eq, {a, b}), Result(uint32_t{a == b})) << a << "==" << b; |
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 want to avoid using floating point comparison on the result side, because then the test is effectively EXPECT(a == b, a == b)
. This may be enough to detect a typo in the implementation, but if the C++ compiler is wrong, it is likely to be wrong in both places.
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.
That is a good point, I'd rather document these requirements/decision as comments in the test.
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.
Ok, feel free to delete my commit
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.
Added comments and dropped the commit.
Co-authored-by: Alex Beregszaszi <alex@rtfs.hu>
3524d8e
to
abc3358
Compare
Depends on #448.
Need to be cleaned up and unit tests.