-
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
Arithmetic operations with integers and intervals #594
Conversation
More tests are perhaps needed... |
Aren't there issues with rounding if the integer is too big to represent exactly as a float, ie larger than 2^52 (?) |
Good point! Indeed, that creates a problem with rounding.... |
A priori I am against this change; it is not a guaranteed operation. Integers can be produced in various ways which do not comply with interval arithmetic specifications. I believe this is the meaning of @Kolaru's comment #590 (comment). The That being said, it is debatable for literal numbers (whether they are floats or integers or any other types). The problem is that it is not clear how to identify them. In fact, I am not even sure they can be distinguished from constant folded (from Julia's compiler) numbers... |
I agree with you that the operation is not guaranteed in general, certainly not for for large integers ( julia> setdisplay(:full);
julia> IntervalArithmetic.atomic(Float64,string(2.0^54)) # no need to round
BareInterval{Float64}(1.8014398509481984e16, 1.8014398509481984e16)
julia> isthin(ans)
true
julia> IntervalArithmetic.atomic(Float64,string(2.0^54+6)) # rounding is needed!
BareInterval{Float64}(1.8014398509481988e16, 1.801439850948199e16)
julia> isthin(ans)
false (I think 2^54+6 is a the first Why do I care about this: essentially, many algorithms (in TaylorSeries) involve things like
I agree, though I think that "origin of operands" at the end refers to the (finite) representation in some float format, which may involve rounding:
I think the code above shows the point of David: inspite of passing a literal The point to debate is whether we allow the user to write code like |
We have no choice but force the user to write
There are two separate problems. The one we care for is the parsing of numbers, not the correct rounding. More concretely, in generic code we might want to use intervals as inputs and may end up with a computation Now, if one types The last scenario is if one types explicitly the number in their code, as in |
I agree; perhaps the way to overcome this, in a systematic way, is to revive I will close this PR; we should continue the discussion in #595 |
Operations with integers should be promoted, since there are no issues with rounding,. I've hand-coded this operations to avoiding promotion.