-
Notifications
You must be signed in to change notification settings - Fork 9
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
xbox: Implement nexttoward() #32
Conversation
@@ -1,20 +1,108 @@ | |||
#include <math.h> | |||
#include <assert.h> | |||
|
|||
// Adapted from public domain code by Danny Smith <[email protected]> |
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.
nit: I'd put this comment in the first line, so it's clear that this affects the entire file, and not just this function (even though the blank line hints at this).
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.
Done.
} | ||
|
||
long double nexttowardl(long double x, long double y) | ||
{ | ||
assert(0); // Not implemented | ||
return 0.0; | ||
static_assert(sizeof(double) == sizeof(long double), "This function assumes that long double and double are the same size."); |
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.
nit: I probably prefer a shorter message like "long double and double must be the same size".
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.
Wow, I managed to miss your comment earlier. It's changed now. I also made nexttowardl
simply call nexttoward
, it just was the same code anyway, so there's no reason to duplicate it.
Code looks good, builds without warnings. I haven't tested the functionality myself but I trust cygwin. |
Thanks @thrimbor I removed that work-around in Peanut-GB and was successfully able to compile and run with this change |
I've since tested with Peanut-gb too. Works as expected.👍 |
I saw that @Ryzee119's Peanut-GB port works around our lack of
nexttowardf
, so I decided to quickly add an implementation. The code is taken from a public domain implementation by Danny Smith and slightly adapted (mostly indentation and curly braces changes).Even though the code comes from Cygwin and I expect it to be tested, I ran a few quick tests against glibc, using positive and negative numbers as well as combinations with
NAN
andINFINITY
, and the results matched.