aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthery2007-05-15 15:02:08 +0000
committerthery2007-05-15 15:02:08 +0000
commit0a64c8ac6a9be66c7cbfe5c110b480e0abbce638 (patch)
tree6586ffc1457f97de0cb7478df1cbee9557451a35
parent3573f36f64cc9887b87e24e1df1299f159572560 (diff)
pos_mod fixed
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@9824 85f007b7-540e-0410-9357-904b9bb8a0f7
-rw-r--r--theories/Ints/BigN.v18
1 files changed, 13 insertions, 5 deletions
diff --git a/theories/Ints/BigN.v b/theories/Ints/BigN.v
index 47a58e278c..2ad6ef0307 100644
--- a/theories/Ints/BigN.v
+++ b/theories/Ints/BigN.v
@@ -66,11 +66,19 @@ Definition int31_op : znz_op int31.
(* shift operations *)
exact (fun p => let (_,i) := positive_to_int31 p in addmuldiv31 i). (*add_mul_div with positive ? *)
- exact (fun p i => let (n,j) := positive_to_int31 p in (*modulo 2^p (p positive) *)
- match n with
- | N0 => let (_,r) := i/j in r
- | _ => i
- end).
+(*modulo 2^p (p positive) *)
+ exact (fun p i =>
+ let (n,j) := positive_to_int31 p in
+ match n with
+ | N0 =>
+ match compare31 j 32 with
+ | Lt => addmuldiv31 j 0 (addmuldiv31 (31-j) i 0)
+ | _ => i
+ end
+ | _ => i
+ end).
+
+
(* is i even ? *)
exact (fun i => let (_,r) := i/2 in
match r ?= 0 with