-
Notifications
You must be signed in to change notification settings - Fork 72
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
convert
can fail to return a valid interval
#539
Comments
Same problem when creating the interval with |
This seems to work fine on julia> x = Float64(π)
3.141592653589793
julia> x ∈ Interval{BigFloat}(x)
true
julia> x ∈ Interval{BigFloat}(Interval(x))
true |
My understanding of the discussion in #51 is that julia> 1//3 ∈ convert(Interval{BigFloat}, 1/3)
true Which works because On the other hand, in almost all cases, julia> x = nextfloat(1.0)
1.0000000000000002
julia> y = convert(Interval{Float32}, x)
[1f0, 1f0]
julia> x ∈ y
false
julia> y.lo == y.hi == rationalize(x) == 1
true From the Julia docs:
I would argue that the use of I think it is also surprising in interactive use, because a user can Something like convert(::Type{Interval{T}}, x::Real) where T = Interval{T}(T(x, RoundDown), T(x, RoundUp)) would have the advantage of returning an interval that contains |
The following conversion fails to return a valid interval:
The problem seems to stem from using
rationalize
; the returned interval is obtained by computingInterval(BigFloat(rationalize(x), RoundDown), BigFloat(rationalize(x), RoundUp))
.However, if
x
is wrapped as anInterval
, then the returned interval is valid:where here the interval is obtained by computing
Interval(BigFloat(x, RoundDown), BigFloat(x, RoundUp))
.The text was updated successfully, but these errors were encountered: