Commit d0a38784 by Mart Lubbers

### adapt ^ instance for Integer

parent 4f75fdde
Pipeline #31795 failed with stage
in 2 minutes and 13 seconds
 ... ... @@ -42,16 +42,40 @@ where instance ^ Integer where (^) :: !Integer !Integer -> Integer (^) x n | n < zero = abort "^ (Integer) called with negative power argument" = pow x n | size n.integer_a==0 | n.integer_s<=0 | n.integer_s==0 = one = negative_power_error = pow x n.integer_s | n.integer_s<0 = negative_power_error | size x.integer_a<>0 || x.integer_s < -1 || x.integer_s > 1 = abort "^ (Integer) overflow" | x.integer_s==1 = one | x.integer_s== -1 | n.integer_a.[0] bitand 1==0 = one = ~one = zero where pow :: !Integer !Int -> Integer pow a b | b == zero = one # x = pow a (b / toInteger 2) | isEven b = x * x | b<=2 | b==2 = a * a = a # x = pow x (b >> 1) | b bitand 1==0 = x * x = a * x * x negative_power_error = abort "^ (Integer) called with negative power argument" instance isEven Integer where isEven {integer_s=s,integer_a=a} ... ... @@ -102,8 +126,6 @@ instance rem Integer where (rem) a b = rem_integer a b //instance ^ Integer instance == Integer where (==) {integer_s=s1,integer_a=a1} {integer_s=s2,integer_a=a2} ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!