-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fix comparisons between Float64 and Int64 #257
Comments
Actually, I forgot that I hadn't actually fixed |
I worked on this a bit and prototyped by writing C functions. For equality, I believe it works just to cast both ways:
If f is out of int range, the first one will fail. If it's in range but you have a non-integer, the second one will fail. The corner case is when f==2^63 and i==typemax(Int64). Then the first check actually passes, but I think we can rely on (int64_t)f giving 0 or typemin(Int64), thereby failing. This is what I have for less than:
The operators are carefully picked to take the float representations of the extreme int values into account. |
These look good. We should also add unit tests for the corner cases. |
For completeness, here are the ones for uint64:
|
Don't we also need
|
I was going to say that we didn't need these anymore since we seem to have decided to implement |
Yes. |
Ok, I'm working on implementing these intrinsics right now. |
Doesn't this work:
? |
Very close, but it gets this case wrong:
|
Seems right to me:
|
huh? |
That's how we convert 2.0^63 to an Int64. As far as I can tell, it's the conversion that's problematic, not the comparison. Unless I'm missing something here. |
2^63 is not representable as an Int64. |
Your example above was |
So that counter-example, as far as I can tell is bogus. However, the comparison |
I was just substituting values into your lt_f64_i64 function:
so the function would attempt
and the first part is true, so it returns true, but |
But not for Uint64:
That's really an awful number for NaN to convert to. It's literally right in the middle of the range of valid Uint64 values. |
Ok, now I see what you're saying. Guess I need to figure out how to emit a conditional in LLVM's C++ API. |
In Stefan's commit 61fe3b9. |
Can we close this now? I think it's all fixed, no? I should probably write some more tests, however. |
* fix up on package with no manifest * add debug stuff * wut * sigh * fixups
* fix up on package with no manifest * add debug stuff * wut * sigh * fixups
Fix JuliaLang#256. This is a very confusing exercise and I don't think we can save it.
…1061ecc (#55615) Stdlib: Downloads URL: https://github.com/JuliaLang/Downloads.jl.git Stdlib branch: master Julia branch: backports-release-1.11 Old commit: a9d274f New commit: 1061ecc Julia version: 1.11.0-rc2 Downloads version: 1.6.0(It's okay that it doesn't match) Bump invoked by: @IanButterworth Powered by: [BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl) Diff: JuliaLang/Downloads.jl@a9d274f...1061ecc ``` $ git log --oneline a9d274f..1061ecc 1061ecc Fix setting atexit. Fixes trailing download tasks during precompilation (#257) b871386 Add debug information to `setopt` commands (#248) 51e5321 fix: use invokelatest for easy_hook, avoid race (#241) 05f9ec2 make precompile workload relocatable (#236) 2dd891a Hardcode doc edit backlink (#232) ``` Co-authored-by: Dilum Aluthge <[email protected]>
We currently promote to Float64, which gives the wrong answer in cases like these:
The text was updated successfully, but these errors were encountered: