Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Why3
why3
Commits
7fdaad84
Commit
7fdaad84
authored
Sep 17, 2015
by
Guillaume Melquiond
Browse files
Do not adjust the remainder of computer_div_mod if it is zero.
This fixes (-2) mod 2 being evaluated as nonzero.
parent
baae8180
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/util/bigInt.ml
View file @
7fdaad84
...
...
@@ -44,13 +44,13 @@ let euclidean_div x y = fst (euclidean_div_mod x y)
let
euclidean_mod
x
y
=
snd
(
euclidean_div_mod
x
y
)
let
computer_div_mod
x
y
=
let
q
,
r
=
quomod_big_int
x
y
in
let
(
q
,
r
)
as
qr
=
quomod_big_int
x
y
in
(* we have x = q*y + r with 0 <= r < |y| *)
if
sign
x
<
0
then
if
sign
x
>=
0
||
sign
r
=
0
then
qr
else
if
sign
y
<
0
then
(
pred
q
,
add
r
y
)
else
(
succ
q
,
sub
r
y
)
else
(
q
,
r
)
let
computer_div
x
y
=
fst
(
computer_div_mod
x
y
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment