-
Notifications
You must be signed in to change notification settings - Fork 71
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 display of -0.0 to 0.0 #500
Conversation
Example: # Currently in master
julia> f(x) = 1 - x^4 + x^5
f (generic function with 1 method)
julia> ff = f(0..1)
[-0, 2]
# With this PR
julia> f(x) = 1 - x^4 + x^5
f (generic function with 1 method)
julia> ff = f(0..1)
[0, 2] |
From the printing side great! |
Almost, but not quite. The following still doesn't look nice: julia> interval(0.0, -0.0)
[0, -0] Maybe having that zero returns always with positive sign is the best. Other opinions? |
I think calling the Regarding the issue I linked: is the -0 vs 0 just a printing thing or do we actually have to make sure that 0 has the bitstring of -0 when it's in the lower bound and the bitstring of +0 when is in the upper bound? This is anyway tangential to this PR |
I think ±0 are considered identical (two representations of the same number). julia> x = -0.0
-0.0
julia> y = 0.0
0.0
julia> x < y
false
julia> x > y
false
julia> x == y
true
`` |
they have different bit representation julia> +0.0 === -0.0
false
julia> bitstring(+0.0)
"0000000000000000000000000000000000000000000000000000000000000000"
julia> bitstring(-0.0)
"1000000000000000000000000000000000000000000000000000000000000000" There are a couple of points in this standard where this small nuisance matters sec 12.12.8
hence e.g. julia> inf(0..0) |> bitstring
"0000000000000000000000000000000000000000000000000000000000000000" would contradict that point. (That's actually a test in ITF1788) I would need to double check the ITF1788 testsuite to see if that's the only place where you actually check that you get a -0, but I think it is. SUMMA SUMMARUM:
|
The signed zero is a floating-point arithmetic feature, if i recall correctly, to have a unique answer for the @lucaferranti Am I understanding you correct that the interval standard imposes that (I'm having a busy morning. I'll try to get back to this in the afternoon) |
I doubt it, for example the Octave package also displayes >> a = infsup(0.0, -0.0)
a = [0]
>> b = infsup(0.0, 1.0)
b = [0, 1]
>> c = infsup(-1, -0.0)
c = [-1, 0]
>> inf(a)
ans = 0
>> inf(b)
ans = 0
>> sup(c)
ans = 0
>> format 'bit'
>> inf(a)
ans = 100000000000000000000000000000000000000000000000000
0000000000000
>> inf(b)
ans = 100000000000000000000000000000000000000000000000000
0000000000000
>> sup(a)
ans = 000000000000000000000000000000000000000000000000000
0000000000000
>> sup(c)
ans = 000000000000000000000000000000000000000000000000000
0000000000000 |
Codecov Report
@@ Coverage Diff @@
## master #500 +/- ##
==========================================
- Coverage 91.09% 90.94% -0.15%
==========================================
Files 25 25
Lines 1785 1789 +4
==========================================
+ Hits 1626 1627 +1
- Misses 159 162 +3
Continue to review full report at Codecov.
|
I think this commit now fixes #473. Using it we have: julia> -0 .. 0
[0, 0]
julia> dump( -0 .. 0)
Interval{Float64}
lo: Float64 0.0
hi: Float64 0.0
julia> dump( 0 .. -0)
Interval{Float64}
lo: Float64 0.0
hi: Float64 0.0
julia> inf(0 .. 0)
-0.0
julia> inf(-0 .. 0)
-0.0
julia> sup( -0 .. -0)
0.0 |
@lbenet I left a couple of comments but overall LGTM |
I just pushed a new commit, getting rid of the Thanks a lot @lucaferranti for finding the tiny little uncomfortable issue in the |
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 think this is ready to be merged too! (maybe bump the patch version?) 🎉
Done! |
Merging... |
See this comment for the motivation.