IntervalArithmetic.jl icon indicating copy to clipboard operation
IntervalArithmetic.jl copied to clipboard

Rethink ..

Open dpsanders opened this issue 6 years ago • 9 comments

I believe this has been raised before, but I think a..b should no longer do "magic" rounding.

Apart from the performance aspect, this is to bring this usage into line with that of IntervalSets.jl, ApproxFun.jl etc. Then we can depend on / interoperate with IntervalSets.jl instead of being in conflict with them.

If a user wants the magic rounding, they should use the macros: the string macro or @interval:

julia> I"0.1..0.2"
[0.0999999, 0.100001]

julia> @interval(0.1, 0.2)
[0.0999999, 0.200001]

We should allow @interval 0.1..0.2 too.

cc @lbenet @Kolaru

dpsanders avatar Dec 16 '19 20:12 dpsanders

This would make a .. b an alias of Interval(a, b), which seems very reasonnable, so I'm in favor of this.

Kolaru avatar Dec 16 '19 22:12 Kolaru

Yes, or rather interval(a, b) (the version with checking).

dpsanders avatar Dec 17 '19 00:12 dpsanders

I agree, as long as there is a simple way of getting rounding correctly. I do think that what makes IntervalArithmetic special, is the correct rounding.

lbenet avatar Dec 17 '19 00:12 lbenet

Mmmm, isn't #347 precisely the opposite to https://github.com/JuliaMath/IntervalSets.jl/issues/33? In any case, I agree that we should share the meaning of alike symbols.

lbenet avatar Dec 17 '19 01:12 lbenet

No, that's what Sheehan was saying in that issue if I'm not mistaken? That it should round up the irrational (but currently doesn't).

dpsanders avatar Dec 17 '19 01:12 dpsanders

I agree with what you say; but if we follow the suggestion discussed here, 0.. pi will not round up. Or do we want also to make an exception with irrationals?

lbenet avatar Dec 17 '19 01:12 lbenet

Well, it's not exactly an exception: We have to round them either down or up, so let's choose the one that actually includes the irrational!

dpsanders avatar Dec 17 '19 01:12 dpsanders

But can't you actually argue the same for 0 .. 0.1?

lbenet avatar Dec 17 '19 01:12 lbenet

No, because 0.1 is a well-defined exact floating-point number.

dpsanders avatar Dec 17 '19 01:12 dpsanders