-
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
Empty interval as [NaN, NaN]? #408
Comments
As far as I can see, the standard mandates what |
Indeed in section 14.2, one possible representation is given as |
It is indeed worth trying it. I am not so sure if we can avoid checking if an interval is empty or not, though. Maybe we should inline |
Julia should inline it automatically. My idea is that e.g. for defining
should then work correctly even for empty intervals, without the explicit empty check. |
Isn't the same true with |
Unfortunately not: julia> add(x, y) = Interval(x.lo + y.lo, x.hi + y.hi)
add (generic function with 1 method)
julia> add(emptyinterval(Float64), entireinterval(Float64))
[NaN, NaN] |
But... julia> add(emptyinterval(Float64), 1..1)
∅ |
Yes it works for most intervals, but not for the example I posted, so you would still need the check. Using |
You are right... Why don't you simply test your proposal? |
Yes I intend to -- I just wanted to see if there was a reason that I was missing why this is a priori a bad idea. I think we used |
I think it would be mostly fine, but this calls for some caution about how to access bounds, since |
Yes agreed. Basically we should avoid directly accessing |
This is interesting; it does help performance a bit. One issue is that |
Is there anything to stop us using
Interval(NaN, NaN)
as the representation of the empty interval? I think this would remove the need for a lot ofisempty
checks, and hence may improve performance (although this would need to be checked).The text was updated successfully, but these errors were encountered: