-
Notifications
You must be signed in to change notification settings - Fork 84
Fix interval division #1804
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
Fix interval division #1804
Conversation
| let is_zero v = Ints_t.compare v Ints_t.zero = 0 in | ||
| match y1, y2 with | ||
| | l, u when is_zero l && is_zero u -> (top_of ik,{underflow=false; overflow=false}) | ||
| | l, _ when is_zero l -> div ik (Some (x1,x2)) (Some (Ints_t.one,y2)) | ||
| | _, u when is_zero u -> div ik (Some (x1,x2)) (Some (y1, Ints_t.(neg one))) | ||
| | _ when leq (of_int ik (Ints_t.zero) |> fst) (Some (y1,y2)) -> (top_of ik,{underflow=false; overflow=false}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, I'm not sure why, but the old handling of division by 0 is quite inconsistent (i.e. not monotone in the second argument):
x / [0, 0]returns top (for division by 0).x / [0, 42]delegates tox / [1, 42], which doesn't return top.x / [-42, 0]delegates tox / [-42, -1], which doesn't return top.x / [-42, 42]again returns top (for division by 0).
The new handling consistently returns top in all of the above cases.
Maybe the goal was to imitate the kind of split at 0 which is now part of the general logic in IArith.div?
Closes #1803.
TODO
leqcheck.