Skip to content

Commit 9c9f235

Browse files
committed
Use Euclidean division to match what Int does
1 parent d8af696 commit 9c9f235

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Data/BigInt.purs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ foreign import biMod :: BigInt -> BigInt -> BigInt
181181
instance commutativeRingBigInt :: CommutativeRing BigInt
182182

183183
instance euclideanRingBigInt :: EuclideanRing BigInt where
184-
div = biDiv
185-
mod = biMod
184+
div x y = (x - x `mod` y) `biDiv` y
185+
186+
mod x y = ((x `biMod` yy) + yy) `biMod` yy
187+
where yy = abs y
188+
186189
degree = floor <<< toNumber <<< abs

0 commit comments

Comments
 (0)