IntervalArithmetic.jl
IntervalArithmetic.jl copied to clipboard
Incorrect construction of Interval{Float64} from Rational{Int}
The rational number 1//10
does not have an exact floating point representation. However currently
julia> x = Interval{Float64}(1//10)
[0.1, 0.100001]
julia> x.lo == x.hi
true
So the interval [x.lo,x.hi]
can definitely not contain 1//10
.
The relevant codepath is https://github.com/JuliaIntervals/IntervalArithmetic.jl/blob/d3a318c6356515ee2d2a0c47ab7af419dea106ea/src/intervals/intervals.jl#L65
Rounding is handled by the @interval
macro, which generates correctly-rounded intervals.
julia> x = @interval(1//10)
Interval(0.09999999999999999, 0.1)
julia> x.lo == x.hi
false
Many thanks for clarifying this.
I think that the original point is valid though - the result should be an Interval contiaing 1//10.
As it is for pi, for example.
This is resolved on master.