summaryrefslogtreecommitdiff
path: root/miralib/ex/divmodtest.m
diff options
context:
space:
mode:
Diffstat (limited to 'miralib/ex/divmodtest.m')
-rw-r--r--miralib/ex/divmodtest.m11
1 files changed, 11 insertions, 0 deletions
diff --git a/miralib/ex/divmodtest.m b/miralib/ex/divmodtest.m
new file mode 100644
index 0000000..28b5e03
--- /dev/null
+++ b/miralib/ex/divmodtest.m
@@ -0,0 +1,11 @@
+||This script defines tests for three properties of div and mod, each
+||checked over a small range of values including various combinations
+||of signs. Each test should yield the result True, or there is
+||something wrong with the arithmetic on your machine!
+
+test1 = and [a div b = entier (a/b) | a,b <- [-15..15]; b~=0]
+test2 = and [b*(a div b) + a mod b = a | a,b <- [-15..15]; b~=0]
+test3 = and [ ok a b | a,b <- [-15..15]; b~=0]
+ where
+ ok a b = 0 <= a mod b < b, if b>0
+ = b < a mod b <= 0, if b<0