Skip to content
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

(possibly) small bug in constructing very tiny intervals with .. #464

Closed
lucaferranti opened this issue May 25, 2021 · 1 comment · Fixed by #567
Closed

(possibly) small bug in constructing very tiny intervals with .. #464

lucaferranti opened this issue May 25, 2021 · 1 comment · Fixed by #567

Comments

@lucaferranti
Copy link
Member

I am trying to construct the interval [1.0000000000000001, 1.0000000000000002]. Note that the lower bound is parsed to the float 1.0 and the upper bound is the next float. If I create the interval with .., then the upper bound is converted to its previous float in this case.

julia> a =  1.0000000000000001
1.0

julia> b =  1.0000000000000002
1.0000000000000002

julia> i1 = a..b
[1, 1]

julia> diam(i1)
0.0

julia> i1.lo == i1.hi
true

julia> i2 = interval(a, b)
[1, 1.00001]

julia> diam(i2)
2.220446049250313e-16

julia> i2.lo == i2.hi
false

interval does not have this issue, so I think the problem is with .. calling rationalize somewhere under the hood. I haven't checked the details of rationalize source code, but I think to remember it uses some continued fractions expansions under the hood. I guess that floating point numbers which are only a few ulps away are converted to the same rational number.

@lucaferranti
Copy link
Member Author

This is actually a test in the ITF1788 testsuite:

b-textToInterval "[1.0000000000000001, 1.0000000000000002]" = [1.0, 0x1.0000000000001p+0] signal PossiblyUndefinedOperation;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants