-
-
Notifications
You must be signed in to change notification settings - Fork 177
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
Bug fix for cmpReals
- mixed compare on negative values
#1197
Comments
I think there is still a problem if i1 is the largest negative integer as in that case abs(i1) is wrong, no? |
Good catch. Since at that magnitude of integers, floating point values are very sparse, comparing with
so how about:
|
Trying to simplify things, I came to
Testing using this works fine until M = 53. Above that we start to see errors. That looks wrong to me. Am I right?
|
Ok. I think this is to be expected. Floats have 54 bits precision. Above that, float(I) and I may no longer compare equal. That means we should be safe. |
A couple of issues with the test:
(Oops, too late). |
I didn't want to change the Prolog flags and I only wanted to test 64 bit ints, so these are big enough. |
I tried replacing my version with the one you committed and got the following build error:
Maybe a platform issue? Or an old clone? |
No. It is defined in the current HEAD. The macro provides an efficient way to map the comparison of two scalars to -1, 0, 1. |
So is that something that the two functions immediately above |
Ideally, yes. There is not a big hurry. The final code is a little shorter and faster, but barely noticeable. |
Agreed - more of a code clean up (for ease of future maintenance). |
Note: unable to generate a PR on recent clone due to outstanding PR #1144.
File:
pl-gmp.c
, Function:cmp_i_f(int64_t i1, double d2)
currently has a bug which compare two negative values as equal when they are close in value, e.g.,
Buggy code:
should be replaced by:
or equivalent.
The text was updated successfully, but these errors were encountered: