diff --git a/ghc/tests/numeric/should_run/arith003.hs b/ghc/tests/numeric/should_run/arith003.hs
index 6102b6bd615d4e4797eb9709e59ee8d17100dc21..c2162ba57f427ea818c24c2d708d357e8282a22b 100644
--- a/ghc/tests/numeric/should_run/arith003.hs
+++ b/ghc/tests/numeric/should_run/arith003.hs
@@ -1,140 +1,76 @@
--- !!! test arithmetic operations from "Prelude" (gcd, lcm, etc.)
+-- $Id: arith003.hs,v 1.4 2000/01/20 13:38:42 simonmar Exp $
 --
+-- !!! test Int/Integer arithmetic operations from the Prelude.
+--
+
 main
   = putStr
-       (-- w/ Ints
-	show [
-	    minInt, maxInt,
-
-	    subtract i8 i4,
-	    subtract i8m i4,
-	    subtract maxInt i4,
-	    subtract i0 minInt,
-
-	    gcd i8 i6,
-	    gcd i8m i6,
-	    gcd i8m i6m,
-	    gcd i8m i0,
-	    gcd i0 i8m,
-	    gcd (4070297::Int) (2695911::Int), -- 52,861
-    
-	    lcm i8 i6,
-	    lcm i8m i6,
-	    lcm i8m i6m,
-	    lcm i8m i0,
-	    lcm i0 i8m,
-	    lcm (4070297::Int) (2695911::Int), -- 207,585,147
-
-	    i8 ^ i0,
-	    i8m ^ i4,
-	    i4 ^ i6
-	    -- ToDo: more stuff
-
-	    ]
-    	++ "\n"
+       (
+	showit (do_ops int_ops) ++
+	showit (do_ops integer_ops)
+    	)
 
-	++ show [
-	    quotRem i8 i6,
-	    quotRem i8m i6,
-	    quotRem i8m i6m,
-	    -- quotRem i8m i0,  -- no div by zero
-	    quotRem i0 i8m,
-	    quotRem (4070297::Int) (2695911::Int), -- 52,861
+showit :: Integral a => [(String, a, a, a)] -> String
+showit stuff = concat
+       [ str ++ " " ++ show l ++ " " ++ show r ++ " = " ++ show result ++ "\n"
+         | (str, l, r, result) <- stuff
+       ]
 
-	    divMod i8 i6,
-	    divMod i8m i6,
-	    divMod i8m i6m,
-	    -- divMod i8m i0,  -- no div by zero
-	    divMod i0 i8m,
-	    divMod (4070297::Int) (2695911::Int) -- 52,861
-            ]
-    	++ "\n"
+do_ops :: Integral a => [((a -> a -> a), String, [(a,a)])]
+	-> [(String, a, a, a)]
+do_ops ops = [ (str, l, r, l `op` r) | (op,str,args) <- ops, (l,r) <- args ]
 
-        -- w/ Integers
-	++ show [
-	    minIntI, maxIntI,
+small_operands, non_min_operands, operands, non_max_operands
+   :: Integral a => [a]
+small_operands  = [ 0, 1, -1, 2, -2 ]
+operands = small_operands ++ [ fromIntegral minInt, fromIntegral maxInt ]
+non_min_operands = small_operands ++ [ fromIntegral maxInt ]
+non_max_operands = small_operands ++ [ fromIntegral minInt ]
 
-	    subtract i8I i4I,
-	    subtract i8mI i4I,
-	    subtract maxIntI i4I,
-	    subtract i0I minIntI,
+large_operands :: [ Integer ]
+large_operands = operands ++ 
+   [ fromIntegral minInt - 1,
+     fromIntegral maxInt + 1,
+     fromIntegral minInt ^ 2, 
+     fromIntegral maxInt ^ 2
+   ]
 
-	    gcd i8I i6I,
-	    gcd i8mI i6I,
-	    gcd i8mI i6mI,
-	    gcd i8mI i0I,
-	    gcd i0I i8mI,
-	    gcd (4070297::Integer) (2695911::Integer), -- 52,861
-	    gcd minIntI (-1),   -- out of Int range
-	    gcd minIntI (1),
-	    gcd (-1) minIntI,
-	    gcd (1)  minIntI,
-	    
-	    lcm i8I i6I,
-	    lcm i8mI i6I,
-	    lcm i8mI i6mI,
-	    lcm i8mI i0I,
-	    lcm i0I i8mI,
-	    lcm (4070297::Integer) (2695911::Integer), -- 207,585,147
-	    lcm minIntI (-1),   -- out of Int range
-	    lcm minIntI (1),
-	    lcm (-1) minIntI,
-	    lcm (1)  minIntI,
+integer_ops :: [((Integer -> Integer -> Integer), String, [(Integer,Integer)])]
+integer_ops = [ 
+  ((+),  "(+)",  all_ok),
+  ((-),  "(-)",  all_ok),
+  (div,  "div",  large_non_zero_r),
+  (mod,  "mod",  large_non_zero_r),
+  (quot, "quot", large_non_zero_r),
+  (rem,  "rem",  large_non_zero_r),
+  (gcd,  "gcd",  either_non_zero),
+  (lcm,  "lcm",  either_non_zero)
+  ]
 
-	    i8I ^ i0I,
-	    i8mI ^ i4I,
-	    i4I ^ i6I
-	    -- ToDo: more stuff
-	    ]
-    	++ "\n"
-        
-	++ show [
-	    quotRem i8I i6I,
-	    quotRem i8mI i6I,
-	    quotRem i8mI i6mI,
-	    -- quotRem i8mI i0I,  -- no div by zero
-	    quotRem i0I i8mI,
-	    quotRem (4070297::Integer) (2695911::Integer), -- 52,861
-	    quotRem minIntI (-1),   -- out of Int range
-	    quotRem minIntI (1),
-	    quotRem (-1) minIntI,
-	    quotRem (1)  minIntI,
+int_ops :: [((Int -> Int -> Int), String, [(Int,Int)])]
+int_ops = [ 
+  ((+),  "(+)",  all_ok),
+  ((-),  "(-)",  all_ok),
+  ((^),  "(^)",  small_non_neg_r),
+  (div,  "div",  non_min_l_or_zero_r),
+  (mod,  "mod",  non_min_l_or_zero_r),
+  (quot, "quot", non_min_l_or_zero_r),
+  (rem,  "rem",  non_min_l_or_zero_r),
+  (gcd,  "gcd",  either_non_zero),
+  (lcm,  "lcm",  non_max_r_either_non_zero)
+  ]
 
-	    divMod i8I i6I,
-	    divMod i8mI i6I,
-	    divMod i8mI i6mI,
-	    -- divMod i8mI i0I,  -- no div by zero
-	    divMod i0I i8mI,
-	    divMod (4070297::Integer) (2695911::Integer), -- 52,861
-	    divMod minIntI (-1),   -- out of Int range
-	    divMod minIntI (1),
-	    divMod (-1) minIntI,
-	    divMod (1)  minIntI
-	    ]
+all_ok, non_zero_r, either_non_zero, non_min_l_or_zero_r,
+ non_max_r_either_non_zero, small_non_neg_r
+  :: Integral a => [(a,a)]
 
-    	++ "\n"
-    	)
-  where
-    i0, i4, i4m, i6, i6m, i8, i8m :: Int
-    i0 = 0
-    i4 = 4
-    i4m = -4
-    i6 = 6
-    i6m = -6
-    i8 = 8
-    i8m = -8
-
-    i0I, i4I, i4mI, i6I, i6mI, i8I, i8mI :: Integer
-    i0I = 0
-    i4I = 4
-    i4mI = -4
-    i6I = 6
-    i6mI = -6
-    i8I = 8
-    i8mI = -8
+all_ok          = [ (l,r) | l <- operands, r <- operands ]
+large_non_zero_r = [ (l,r) | l <- operands, r <- large_operands, r /= 0 ]
+non_zero_r      = [ (l,r) | l <- operands, r <- operands, r /= 0 ]
+either_non_zero = [ (l,r) | l <- operands, r <- operands, l /= 0 || r /= 0 ]
+small_non_neg_r = [ (l,r) | l <- operands, r <- small_operands, r >= 0 ]
+non_min_l_or_zero_r = [ (l,r) | l <- non_min_operands, r <- operands, r /= 0 ]
+non_max_r_either_non_zero = [ (l,r) | l <- operands, r <- non_max_operands, l /= 0 || r /= 0 ]
 
 minInt = minBound :: Int
 maxInt = maxBound :: Int
-
-minIntI = fromIntegral minInt :: Integer
-maxIntI = fromIntegral maxInt :: Integer
diff --git a/ghc/tests/numeric/should_run/arith003.stdout b/ghc/tests/numeric/should_run/arith003.stdout
index c02805f1d006ba01a89ba3335be3491b89b2e3d0..b5082450ec8d9412bebba9e58b379e7540e4b2d2 100644
--- a/ghc/tests/numeric/should_run/arith003.stdout
+++ b/ghc/tests/numeric/should_run/arith003.stdout
@@ -1,2 +1,826 @@
-[-2147483648,2147483647,-4,12,-2147483643,-2147483648,2,2,2,8,8,52861,24,24,24,0,0,207585147,1,4096,4096]
-[-2147483648,2147483647,-4,12,-2147483643,-2147483648,2,2,2,8,8,52861,24,24,24,0,0,207585147,1,4096,4096]
+(+) 0 0 = 0
+(+) 0 1 = 1
+(+) 0 -1 = -1
+(+) 0 2 = 2
+(+) 0 -2 = -2
+(+) 0 -2147483648 = -2147483648
+(+) 0 2147483647 = 2147483647
+(+) 1 0 = 1
+(+) 1 1 = 2
+(+) 1 -1 = 0
+(+) 1 2 = 3
+(+) 1 -2 = -1
+(+) 1 -2147483648 = -2147483647
+(+) 1 2147483647 = -2147483648
+(+) -1 0 = -1
+(+) -1 1 = 0
+(+) -1 -1 = -2
+(+) -1 2 = 1
+(+) -1 -2 = -3
+(+) -1 -2147483648 = 2147483647
+(+) -1 2147483647 = 2147483646
+(+) 2 0 = 2
+(+) 2 1 = 3
+(+) 2 -1 = 1
+(+) 2 2 = 4
+(+) 2 -2 = 0
+(+) 2 -2147483648 = -2147483646
+(+) 2 2147483647 = -2147483647
+(+) -2 0 = -2
+(+) -2 1 = -1
+(+) -2 -1 = -3
+(+) -2 2 = 0
+(+) -2 -2 = -4
+(+) -2 -2147483648 = 2147483646
+(+) -2 2147483647 = 2147483645
+(+) -2147483648 0 = -2147483648
+(+) -2147483648 1 = -2147483647
+(+) -2147483648 -1 = 2147483647
+(+) -2147483648 2 = -2147483646
+(+) -2147483648 -2 = 2147483646
+(+) -2147483648 -2147483648 = 0
+(+) -2147483648 2147483647 = -1
+(+) 2147483647 0 = 2147483647
+(+) 2147483647 1 = -2147483648
+(+) 2147483647 -1 = 2147483646
+(+) 2147483647 2 = -2147483647
+(+) 2147483647 -2 = 2147483645
+(+) 2147483647 -2147483648 = -1
+(+) 2147483647 2147483647 = -2
+(-) 0 0 = 0
+(-) 0 1 = -1
+(-) 0 -1 = 1
+(-) 0 2 = -2
+(-) 0 -2 = 2
+(-) 0 -2147483648 = -2147483648
+(-) 0 2147483647 = -2147483647
+(-) 1 0 = 1
+(-) 1 1 = 0
+(-) 1 -1 = 2
+(-) 1 2 = -1
+(-) 1 -2 = 3
+(-) 1 -2147483648 = -2147483647
+(-) 1 2147483647 = -2147483646
+(-) -1 0 = -1
+(-) -1 1 = -2
+(-) -1 -1 = 0
+(-) -1 2 = -3
+(-) -1 -2 = 1
+(-) -1 -2147483648 = 2147483647
+(-) -1 2147483647 = -2147483648
+(-) 2 0 = 2
+(-) 2 1 = 1
+(-) 2 -1 = 3
+(-) 2 2 = 0
+(-) 2 -2 = 4
+(-) 2 -2147483648 = -2147483646
+(-) 2 2147483647 = -2147483645
+(-) -2 0 = -2
+(-) -2 1 = -3
+(-) -2 -1 = -1
+(-) -2 2 = -4
+(-) -2 -2 = 0
+(-) -2 -2147483648 = 2147483646
+(-) -2 2147483647 = 2147483647
+(-) -2147483648 0 = -2147483648
+(-) -2147483648 1 = 2147483647
+(-) -2147483648 -1 = -2147483647
+(-) -2147483648 2 = 2147483646
+(-) -2147483648 -2 = -2147483646
+(-) -2147483648 -2147483648 = 0
+(-) -2147483648 2147483647 = 1
+(-) 2147483647 0 = 2147483647
+(-) 2147483647 1 = 2147483646
+(-) 2147483647 -1 = -2147483648
+(-) 2147483647 2 = 2147483645
+(-) 2147483647 -2 = -2147483647
+(-) 2147483647 -2147483648 = -1
+(-) 2147483647 2147483647 = 0
+(^) 0 0 = 1
+(^) 0 1 = 0
+(^) 0 2 = 0
+(^) 1 0 = 1
+(^) 1 1 = 1
+(^) 1 2 = 1
+(^) -1 0 = 1
+(^) -1 1 = -1
+(^) -1 2 = 1
+(^) 2 0 = 1
+(^) 2 1 = 2
+(^) 2 2 = 4
+(^) -2 0 = 1
+(^) -2 1 = -2
+(^) -2 2 = 4
+(^) -2147483648 0 = 1
+(^) -2147483648 1 = -2147483648
+(^) -2147483648 2 = 0
+(^) 2147483647 0 = 1
+(^) 2147483647 1 = 2147483647
+(^) 2147483647 2 = 1
+div 0 1 = 0
+div 0 -1 = 0
+div 0 2 = 0
+div 0 -2 = 0
+div 0 -2147483648 = 0
+div 0 2147483647 = 0
+div 1 1 = 1
+div 1 -1 = -1
+div 1 2 = 0
+div 1 -2 = -1
+div 1 -2147483648 = 1
+div 1 2147483647 = 0
+div -1 1 = -1
+div -1 -1 = 1
+div -1 2 = -1
+div -1 -2 = 0
+div -1 -2147483648 = 0
+div -1 2147483647 = -1
+div 2 1 = 2
+div 2 -1 = -2
+div 2 2 = 1
+div 2 -2 = -1
+div 2 -2147483648 = 0
+div 2 2147483647 = 0
+div -2 1 = -2
+div -2 -1 = 2
+div -2 2 = -1
+div -2 -2 = 1
+div -2 -2147483648 = 0
+div -2 2147483647 = -1
+div 2147483647 1 = 2147483647
+div 2147483647 -1 = -2147483647
+div 2147483647 2 = 1073741823
+div 2147483647 -2 = 1073741824
+div 2147483647 -2147483648 = 0
+div 2147483647 2147483647 = 1
+mod 0 1 = 0
+mod 0 -1 = 0
+mod 0 2 = 0
+mod 0 -2 = 0
+mod 0 -2147483648 = 0
+mod 0 2147483647 = 0
+mod 1 1 = 0
+mod 1 -1 = 0
+mod 1 2 = 1
+mod 1 -2 = -1
+mod 1 -2147483648 = -2147483647
+mod 1 2147483647 = 1
+mod -1 1 = 0
+mod -1 -1 = 0
+mod -1 2 = 1
+mod -1 -2 = -1
+mod -1 -2147483648 = -1
+mod -1 2147483647 = 2147483646
+mod 2 1 = 0
+mod 2 -1 = 0
+mod 2 2 = 0
+mod 2 -2 = 0
+mod 2 -2147483648 = -2147483646
+mod 2 2147483647 = 2
+mod -2 1 = 0
+mod -2 -1 = 0
+mod -2 2 = 0
+mod -2 -2 = 0
+mod -2 -2147483648 = -2
+mod -2 2147483647 = 2147483645
+mod 2147483647 1 = 0
+mod 2147483647 -1 = 0
+mod 2147483647 2 = 1
+mod 2147483647 -2 = -1
+mod 2147483647 -2147483648 = -1
+mod 2147483647 2147483647 = 0
+quot 0 1 = 0
+quot 0 -1 = 0
+quot 0 2 = 0
+quot 0 -2 = 0
+quot 0 -2147483648 = 0
+quot 0 2147483647 = 0
+quot 1 1 = 1
+quot 1 -1 = -1
+quot 1 2 = 0
+quot 1 -2 = 0
+quot 1 -2147483648 = 0
+quot 1 2147483647 = 0
+quot -1 1 = -1
+quot -1 -1 = 1
+quot -1 2 = 0
+quot -1 -2 = 0
+quot -1 -2147483648 = 0
+quot -1 2147483647 = 0
+quot 2 1 = 2
+quot 2 -1 = -2
+quot 2 2 = 1
+quot 2 -2 = -1
+quot 2 -2147483648 = 0
+quot 2 2147483647 = 0
+quot -2 1 = -2
+quot -2 -1 = 2
+quot -2 2 = -1
+quot -2 -2 = 1
+quot -2 -2147483648 = 0
+quot -2 2147483647 = 0
+quot 2147483647 1 = 2147483647
+quot 2147483647 -1 = -2147483647
+quot 2147483647 2 = 1073741823
+quot 2147483647 -2 = -1073741823
+quot 2147483647 -2147483648 = 0
+quot 2147483647 2147483647 = 1
+rem 0 1 = 0
+rem 0 -1 = 0
+rem 0 2 = 0
+rem 0 -2 = 0
+rem 0 -2147483648 = 0
+rem 0 2147483647 = 0
+rem 1 1 = 0
+rem 1 -1 = 0
+rem 1 2 = 1
+rem 1 -2 = 1
+rem 1 -2147483648 = 1
+rem 1 2147483647 = 1
+rem -1 1 = 0
+rem -1 -1 = 0
+rem -1 2 = -1
+rem -1 -2 = -1
+rem -1 -2147483648 = -1
+rem -1 2147483647 = -1
+rem 2 1 = 0
+rem 2 -1 = 0
+rem 2 2 = 0
+rem 2 -2 = 0
+rem 2 -2147483648 = 2
+rem 2 2147483647 = 2
+rem -2 1 = 0
+rem -2 -1 = 0
+rem -2 2 = 0
+rem -2 -2 = 0
+rem -2 -2147483648 = -2
+rem -2 2147483647 = -2
+rem 2147483647 1 = 0
+rem 2147483647 -1 = 0
+rem 2147483647 2 = 1
+rem 2147483647 -2 = 1
+rem 2147483647 -2147483648 = 2147483647
+rem 2147483647 2147483647 = 0
+gcd 0 1 = 1
+gcd 0 -1 = 1
+gcd 0 2 = 2
+gcd 0 -2 = 2
+gcd 0 -2147483648 = -2147483648
+gcd 0 2147483647 = 2147483647
+gcd 1 0 = 1
+gcd 1 1 = 1
+gcd 1 -1 = 1
+gcd 1 2 = 1
+gcd 1 -2 = 1
+gcd 1 -2147483648 = 1
+gcd 1 2147483647 = 1
+gcd -1 0 = 1
+gcd -1 1 = 1
+gcd -1 -1 = 1
+gcd -1 2 = 1
+gcd -1 -2 = 1
+gcd -1 -2147483648 = 1
+gcd -1 2147483647 = 1
+gcd 2 0 = 2
+gcd 2 1 = 1
+gcd 2 -1 = 1
+gcd 2 2 = 2
+gcd 2 -2 = 2
+gcd 2 -2147483648 = 2
+gcd 2 2147483647 = 1
+gcd -2 0 = 2
+gcd -2 1 = 1
+gcd -2 -1 = 1
+gcd -2 2 = 2
+gcd -2 -2 = 2
+gcd -2 -2147483648 = 2
+gcd -2 2147483647 = 1
+gcd -2147483648 0 = -2147483648
+gcd -2147483648 1 = 1
+gcd -2147483648 -1 = 1
+gcd -2147483648 2 = 2
+gcd -2147483648 -2 = 2
+gcd -2147483648 -2147483648 = -2147483648
+gcd -2147483648 2147483647 = -1
+gcd 2147483647 0 = 2147483647
+gcd 2147483647 1 = 1
+gcd 2147483647 -1 = 1
+gcd 2147483647 2 = 1
+gcd 2147483647 -2 = 1
+gcd 2147483647 -2147483648 = -1
+gcd 2147483647 2147483647 = 2147483647
+lcm 0 1 = 0
+lcm 0 -1 = 0
+lcm 0 2 = 0
+lcm 0 -2 = 0
+lcm 0 -2147483648 = 0
+lcm 1 0 = 0
+lcm 1 1 = 1
+lcm 1 -1 = 1
+lcm 1 2 = 2
+lcm 1 -2 = 2
+lcm 1 -2147483648 = -2147483648
+lcm -1 0 = 0
+lcm -1 1 = 1
+lcm -1 -1 = 1
+lcm -1 2 = 2
+lcm -1 -2 = 2
+lcm -1 -2147483648 = -2147483648
+lcm 2 0 = 0
+lcm 2 1 = 2
+lcm 2 -1 = 2
+lcm 2 2 = 2
+lcm 2 -2 = 2
+lcm 2 -2147483648 = -2147483648
+lcm -2 0 = 0
+lcm -2 1 = 2
+lcm -2 -1 = 2
+lcm -2 2 = 2
+lcm -2 -2 = 2
+lcm -2 -2147483648 = -2147483648
+lcm -2147483648 0 = 0
+lcm -2147483648 1 = -2147483648
+lcm -2147483648 -1 = -2147483648
+lcm -2147483648 2 = -2147483648
+lcm -2147483648 -2 = -2147483648
+lcm -2147483648 -2147483648 = -2147483648
+lcm 2147483647 0 = 0
+lcm 2147483647 1 = 2147483647
+lcm 2147483647 -1 = 2147483647
+lcm 2147483647 2 = 2
+lcm 2147483647 -2 = 2
+lcm 2147483647 -2147483648 = -2147483648
+(+) 0 0 = 0
+(+) 0 1 = 1
+(+) 0 -1 = -1
+(+) 0 2 = 2
+(+) 0 -2 = -2
+(+) 0 -2147483648 = -2147483648
+(+) 0 2147483647 = 2147483647
+(+) 1 0 = 1
+(+) 1 1 = 2
+(+) 1 -1 = 0
+(+) 1 2 = 3
+(+) 1 -2 = -1
+(+) 1 -2147483648 = -2147483647
+(+) 1 2147483647 = 2147483648
+(+) -1 0 = -1
+(+) -1 1 = 0
+(+) -1 -1 = -2
+(+) -1 2 = 1
+(+) -1 -2 = -3
+(+) -1 -2147483648 = -2147483649
+(+) -1 2147483647 = 2147483646
+(+) 2 0 = 2
+(+) 2 1 = 3
+(+) 2 -1 = 1
+(+) 2 2 = 4
+(+) 2 -2 = 0
+(+) 2 -2147483648 = -2147483646
+(+) 2 2147483647 = 2147483649
+(+) -2 0 = -2
+(+) -2 1 = -1
+(+) -2 -1 = -3
+(+) -2 2 = 0
+(+) -2 -2 = -4
+(+) -2 -2147483648 = -2147483650
+(+) -2 2147483647 = 2147483645
+(+) -2147483648 0 = -2147483648
+(+) -2147483648 1 = -2147483647
+(+) -2147483648 -1 = -2147483649
+(+) -2147483648 2 = -2147483646
+(+) -2147483648 -2 = -2147483650
+(+) -2147483648 -2147483648 = -4294967296
+(+) -2147483648 2147483647 = -1
+(+) 2147483647 0 = 2147483647
+(+) 2147483647 1 = 2147483648
+(+) 2147483647 -1 = 2147483646
+(+) 2147483647 2 = 2147483649
+(+) 2147483647 -2 = 2147483645
+(+) 2147483647 -2147483648 = -1
+(+) 2147483647 2147483647 = 4294967294
+(-) 0 0 = 0
+(-) 0 1 = -1
+(-) 0 -1 = 1
+(-) 0 2 = -2
+(-) 0 -2 = 2
+(-) 0 -2147483648 = 2147483648
+(-) 0 2147483647 = -2147483647
+(-) 1 0 = 1
+(-) 1 1 = 0
+(-) 1 -1 = 2
+(-) 1 2 = -1
+(-) 1 -2 = 3
+(-) 1 -2147483648 = 2147483649
+(-) 1 2147483647 = -2147483646
+(-) -1 0 = -1
+(-) -1 1 = -2
+(-) -1 -1 = 0
+(-) -1 2 = -3
+(-) -1 -2 = 1
+(-) -1 -2147483648 = 2147483647
+(-) -1 2147483647 = -2147483648
+(-) 2 0 = 2
+(-) 2 1 = 1
+(-) 2 -1 = 3
+(-) 2 2 = 0
+(-) 2 -2 = 4
+(-) 2 -2147483648 = 2147483650
+(-) 2 2147483647 = -2147483645
+(-) -2 0 = -2
+(-) -2 1 = -3
+(-) -2 -1 = -1
+(-) -2 2 = -4
+(-) -2 -2 = 0
+(-) -2 -2147483648 = 2147483646
+(-) -2 2147483647 = -2147483649
+(-) -2147483648 0 = -2147483648
+(-) -2147483648 1 = -2147483649
+(-) -2147483648 -1 = -2147483647
+(-) -2147483648 2 = -2147483650
+(-) -2147483648 -2 = -2147483646
+(-) -2147483648 -2147483648 = 0
+(-) -2147483648 2147483647 = -4294967295
+(-) 2147483647 0 = 2147483647
+(-) 2147483647 1 = 2147483646
+(-) 2147483647 -1 = 2147483648
+(-) 2147483647 2 = 2147483645
+(-) 2147483647 -2 = 2147483649
+(-) 2147483647 -2147483648 = 4294967295
+(-) 2147483647 2147483647 = 0
+div 0 1 = 0
+div 0 -1 = 0
+div 0 2 = 0
+div 0 -2 = 0
+div 0 -2147483648 = 0
+div 0 2147483647 = 0
+div 0 -2147483649 = 0
+div 0 2147483648 = 0
+div 0 4611686018427387904 = 0
+div 0 4611686014132420609 = 0
+div 1 1 = 1
+div 1 -1 = -1
+div 1 2 = 0
+div 1 -2 = -1
+div 1 -2147483648 = 1
+div 1 2147483647 = 0
+div 1 -2147483649 = -1
+div 1 2147483648 = 0
+div 1 4611686018427387904 = 0
+div 1 4611686014132420609 = 0
+div -1 1 = -1
+div -1 -1 = 1
+div -1 2 = -1
+div -1 -2 = 0
+div -1 -2147483648 = 0
+div -1 2147483647 = -1
+div -1 -2147483649 = 0
+div -1 2147483648 = -1
+div -1 4611686018427387904 = -1
+div -1 4611686014132420609 = -1
+div 2 1 = 2
+div 2 -1 = -2
+div 2 2 = 1
+div 2 -2 = -1
+div 2 -2147483648 = 0
+div 2 2147483647 = 0
+div 2 -2147483649 = -1
+div 2 2147483648 = 0
+div 2 4611686018427387904 = 0
+div 2 4611686014132420609 = 0
+div -2 1 = -2
+div -2 -1 = 2
+div -2 2 = -1
+div -2 -2 = 1
+div -2 -2147483648 = 0
+div -2 2147483647 = -1
+div -2 -2147483649 = 0
+div -2 2147483648 = -1
+div -2 4611686018427387904 = -1
+div -2 4611686014132420609 = -1
+div -2147483648 1 = -2147483648
+div -2147483648 -1 = 2147483648
+div -2147483648 2 = -1073741824
+div -2147483648 -2 = 1073741824
+div -2147483648 -2147483648 = 1
+div -2147483648 2147483647 = -2
+div -2147483648 -2147483649 = 0
+div -2147483648 2147483648 = -1
+div -2147483648 4611686018427387904 = -1
+div -2147483648 4611686014132420609 = -1
+div 2147483647 1 = 2147483647
+div 2147483647 -1 = -2147483647
+div 2147483647 2 = 1073741823
+div 2147483647 -2 = 1073741824
+div 2147483647 -2147483648 = 0
+div 2147483647 2147483647 = 1
+div 2147483647 -2147483649 = -1
+div 2147483647 2147483648 = 0
+div 2147483647 4611686018427387904 = 0
+div 2147483647 4611686014132420609 = 0
+mod 0 1 = 0
+mod 0 -1 = 0
+mod 0 2 = 0
+mod 0 -2 = 0
+mod 0 -2147483648 = 0
+mod 0 2147483647 = 0
+mod 0 -2147483649 = 0
+mod 0 2147483648 = 0
+mod 0 4611686018427387904 = 0
+mod 0 4611686014132420609 = 0
+mod 1 1 = 0
+mod 1 -1 = 0
+mod 1 2 = 1
+mod 1 -2 = -1
+mod 1 -2147483648 = -2147483647
+mod 1 2147483647 = 1
+mod 1 -2147483649 = -2147483648
+mod 1 2147483648 = 1
+mod 1 4611686018427387904 = 1
+mod 1 4611686014132420609 = 1
+mod -1 1 = 0
+mod -1 -1 = 0
+mod -1 2 = 1
+mod -1 -2 = -1
+mod -1 -2147483648 = -1
+mod -1 2147483647 = 2147483646
+mod -1 -2147483649 = -1
+mod -1 2147483648 = 2147483647
+mod -1 4611686018427387904 = 4611686018427387903
+mod -1 4611686014132420609 = 4611686014132420608
+mod 2 1 = 0
+mod 2 -1 = 0
+mod 2 2 = 0
+mod 2 -2 = 0
+mod 2 -2147483648 = -2147483646
+mod 2 2147483647 = 2
+mod 2 -2147483649 = -2147483647
+mod 2 2147483648 = 2
+mod 2 4611686018427387904 = 2
+mod 2 4611686014132420609 = 2
+mod -2 1 = 0
+mod -2 -1 = 0
+mod -2 2 = 0
+mod -2 -2 = 0
+mod -2 -2147483648 = -2
+mod -2 2147483647 = 2147483645
+mod -2 -2147483649 = -2
+mod -2 2147483648 = 2147483646
+mod -2 4611686018427387904 = 4611686018427387902
+mod -2 4611686014132420609 = 4611686014132420607
+mod -2147483648 1 = 0
+mod -2147483648 -1 = 0
+mod -2147483648 2 = 0
+mod -2147483648 -2 = 0
+mod -2147483648 -2147483648 = 0
+mod -2147483648 2147483647 = 2147483646
+mod -2147483648 -2147483649 = -2147483648
+mod -2147483648 2147483648 = 0
+mod -2147483648 4611686018427387904 = 4611686016279904256
+mod -2147483648 4611686014132420609 = 4611686011984936961
+mod 2147483647 1 = 0
+mod 2147483647 -1 = 0
+mod 2147483647 2 = 1
+mod 2147483647 -2 = -1
+mod 2147483647 -2147483648 = -1
+mod 2147483647 2147483647 = 0
+mod 2147483647 -2147483649 = -2
+mod 2147483647 2147483648 = 2147483647
+mod 2147483647 4611686018427387904 = 2147483647
+mod 2147483647 4611686014132420609 = 2147483647
+quot 0 1 = 0
+quot 0 -1 = 0
+quot 0 2 = 0
+quot 0 -2 = 0
+quot 0 -2147483648 = 0
+quot 0 2147483647 = 0
+quot 0 -2147483649 = 0
+quot 0 2147483648 = 0
+quot 0 4611686018427387904 = 0
+quot 0 4611686014132420609 = 0
+quot 1 1 = 1
+quot 1 -1 = -1
+quot 1 2 = 0
+quot 1 -2 = 0
+quot 1 -2147483648 = 0
+quot 1 2147483647 = 0
+quot 1 -2147483649 = 0
+quot 1 2147483648 = 0
+quot 1 4611686018427387904 = 0
+quot 1 4611686014132420609 = 0
+quot -1 1 = -1
+quot -1 -1 = 1
+quot -1 2 = 0
+quot -1 -2 = 0
+quot -1 -2147483648 = 0
+quot -1 2147483647 = 0
+quot -1 -2147483649 = 0
+quot -1 2147483648 = 0
+quot -1 4611686018427387904 = 0
+quot -1 4611686014132420609 = 0
+quot 2 1 = 2
+quot 2 -1 = -2
+quot 2 2 = 1
+quot 2 -2 = -1
+quot 2 -2147483648 = 0
+quot 2 2147483647 = 0
+quot 2 -2147483649 = 0
+quot 2 2147483648 = 0
+quot 2 4611686018427387904 = 0
+quot 2 4611686014132420609 = 0
+quot -2 1 = -2
+quot -2 -1 = 2
+quot -2 2 = -1
+quot -2 -2 = 1
+quot -2 -2147483648 = 0
+quot -2 2147483647 = 0
+quot -2 -2147483649 = 0
+quot -2 2147483648 = 0
+quot -2 4611686018427387904 = 0
+quot -2 4611686014132420609 = 0
+quot -2147483648 1 = -2147483648
+quot -2147483648 -1 = 2147483648
+quot -2147483648 2 = -1073741824
+quot -2147483648 -2 = 1073741824
+quot -2147483648 -2147483648 = 1
+quot -2147483648 2147483647 = -1
+quot -2147483648 -2147483649 = 0
+quot -2147483648 2147483648 = -1
+quot -2147483648 4611686018427387904 = 0
+quot -2147483648 4611686014132420609 = 0
+quot 2147483647 1 = 2147483647
+quot 2147483647 -1 = -2147483647
+quot 2147483647 2 = 1073741823
+quot 2147483647 -2 = -1073741823
+quot 2147483647 -2147483648 = 0
+quot 2147483647 2147483647 = 1
+quot 2147483647 -2147483649 = 1
+quot 2147483647 2147483648 = 0
+quot 2147483647 4611686018427387904 = 0
+quot 2147483647 4611686014132420609 = 0
+rem 0 1 = 0
+rem 0 -1 = 0
+rem 0 2 = 0
+rem 0 -2 = 0
+rem 0 -2147483648 = 0
+rem 0 2147483647 = 0
+rem 0 -2147483649 = 0
+rem 0 2147483648 = 0
+rem 0 4611686018427387904 = 0
+rem 0 4611686014132420609 = 0
+rem 1 1 = 0
+rem 1 -1 = 0
+rem 1 2 = 1
+rem 1 -2 = 1
+rem 1 -2147483648 = 1
+rem 1 2147483647 = 1
+rem 1 -2147483649 = 1
+rem 1 2147483648 = 1
+rem 1 4611686018427387904 = 1
+rem 1 4611686014132420609 = 1
+rem -1 1 = 0
+rem -1 -1 = 0
+rem -1 2 = -1
+rem -1 -2 = -1
+rem -1 -2147483648 = -1
+rem -1 2147483647 = -1
+rem -1 -2147483649 = -1
+rem -1 2147483648 = -1
+rem -1 4611686018427387904 = -1
+rem -1 4611686014132420609 = -1
+rem 2 1 = 0
+rem 2 -1 = 0
+rem 2 2 = 0
+rem 2 -2 = 0
+rem 2 -2147483648 = 2
+rem 2 2147483647 = 2
+rem 2 -2147483649 = 2
+rem 2 2147483648 = 2
+rem 2 4611686018427387904 = 2
+rem 2 4611686014132420609 = 2
+rem -2 1 = 0
+rem -2 -1 = 0
+rem -2 2 = 0
+rem -2 -2 = 0
+rem -2 -2147483648 = -2
+rem -2 2147483647 = -2
+rem -2 -2147483649 = -2
+rem -2 2147483648 = -2
+rem -2 4611686018427387904 = -2
+rem -2 4611686014132420609 = -2
+rem -2147483648 1 = 0
+rem -2147483648 -1 = 0
+rem -2147483648 2 = 0
+rem -2147483648 -2 = 0
+rem -2147483648 -2147483648 = 0
+rem -2147483648 2147483647 = -1
+rem -2147483648 -2147483649 = -2147483648
+rem -2147483648 2147483648 = 0
+rem -2147483648 4611686018427387904 = -2147483648
+rem -2147483648 4611686014132420609 = -2147483648
+rem 2147483647 1 = 0
+rem 2147483647 -1 = 0
+rem 2147483647 2 = 1
+rem 2147483647 -2 = 1
+rem 2147483647 -2147483648 = 2147483647
+rem 2147483647 2147483647 = 0
+rem 2147483647 -2147483649 = 0
+rem 2147483647 2147483648 = 2147483647
+rem 2147483647 4611686018427387904 = 2147483647
+rem 2147483647 4611686014132420609 = 2147483647
+gcd 0 1 = 1
+gcd 0 -1 = 1
+gcd 0 2 = 2
+gcd 0 -2 = 2
+gcd 0 -2147483648 = 2147483648
+gcd 0 2147483647 = 2147483647
+gcd 1 0 = 1
+gcd 1 1 = 1
+gcd 1 -1 = 1
+gcd 1 2 = 1
+gcd 1 -2 = 1
+gcd 1 -2147483648 = 1
+gcd 1 2147483647 = 1
+gcd -1 0 = 1
+gcd -1 1 = 1
+gcd -1 -1 = 1
+gcd -1 2 = 1
+gcd -1 -2 = 1
+gcd -1 -2147483648 = 1
+gcd -1 2147483647 = 1
+gcd 2 0 = 2
+gcd 2 1 = 1
+gcd 2 -1 = 1
+gcd 2 2 = 2
+gcd 2 -2 = 2
+gcd 2 -2147483648 = 2
+gcd 2 2147483647 = 1
+gcd -2 0 = 2
+gcd -2 1 = 1
+gcd -2 -1 = 1
+gcd -2 2 = 2
+gcd -2 -2 = 2
+gcd -2 -2147483648 = 2
+gcd -2 2147483647 = 1
+gcd -2147483648 0 = 2147483648
+gcd -2147483648 1 = 1
+gcd -2147483648 -1 = 1
+gcd -2147483648 2 = 2
+gcd -2147483648 -2 = 2
+gcd -2147483648 -2147483648 = 2147483648
+gcd -2147483648 2147483647 = 1
+gcd 2147483647 0 = 2147483647
+gcd 2147483647 1 = 1
+gcd 2147483647 -1 = 1
+gcd 2147483647 2 = 1
+gcd 2147483647 -2 = 1
+gcd 2147483647 -2147483648 = 1
+gcd 2147483647 2147483647 = 2147483647
+lcm 0 1 = 0
+lcm 0 -1 = 0
+lcm 0 2 = 0
+lcm 0 -2 = 0
+lcm 0 -2147483648 = 0
+lcm 0 2147483647 = 0
+lcm 1 0 = 0
+lcm 1 1 = 1
+lcm 1 -1 = 1
+lcm 1 2 = 2
+lcm 1 -2 = 2
+lcm 1 -2147483648 = 2147483648
+lcm 1 2147483647 = 2147483647
+lcm -1 0 = 0
+lcm -1 1 = 1
+lcm -1 -1 = 1
+lcm -1 2 = 2
+lcm -1 -2 = 2
+lcm -1 -2147483648 = 2147483648
+lcm -1 2147483647 = 2147483647
+lcm 2 0 = 0
+lcm 2 1 = 2
+lcm 2 -1 = 2
+lcm 2 2 = 2
+lcm 2 -2 = 2
+lcm 2 -2147483648 = 2147483648
+lcm 2 2147483647 = 4294967294
+lcm -2 0 = 0
+lcm -2 1 = 2
+lcm -2 -1 = 2
+lcm -2 2 = 2
+lcm -2 -2 = 2
+lcm -2 -2147483648 = 2147483648
+lcm -2 2147483647 = 4294967294
+lcm -2147483648 0 = 0
+lcm -2147483648 1 = 2147483648
+lcm -2147483648 -1 = 2147483648
+lcm -2147483648 2 = 2147483648
+lcm -2147483648 -2 = 2147483648
+lcm -2147483648 -2147483648 = 2147483648
+lcm -2147483648 2147483647 = 4611686016279904256
+lcm 2147483647 0 = 0
+lcm 2147483647 1 = 2147483647
+lcm 2147483647 -1 = 2147483647
+lcm 2147483647 2 = 4294967294
+lcm 2147483647 -2 = 4294967294
+lcm 2147483647 -2147483648 = 4611686016279904256
+lcm 2147483647 2147483647 = 2147483647