summaryrefslogtreecommitdiff
path: root/dist/Math-BigRat
diff options
context:
space:
mode:
authorPeter John Acklam <pjacklam@online.no>2011-01-02 13:13:31 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-01-02 14:31:23 -0800
commit487de07a0a3bad1b47206a54968c2b33bde81618 (patch)
treedf8b241f66864ec64a490dc0e14095db7515c252 /dist/Math-BigRat
parent4b24804c085ea7ddbc20fa745c8d326ab5e21f36 (diff)
downloadperl-487de07a0a3bad1b47206a54968c2b33bde81618.tar.gz
[perl #81400] Fix bmodinv() part of RT 63237
The following standard definition is used: z is the modular inverse of x (mod y) if and only if x*z (mod y) = 1 (mod y). - dist/Math-BigInt/lib/Math/BigInt.pm: Fix the code in bmodinv() so it can handle negative arguments. The code can be optimized further for speed, but correctnes first. - dist/Math-BigInt/t/bigintpm.inc: Fix the test case for modinv(-3, -5). The output should be -3, since -3 * -3 (mod -5) = -9 (mod -5) = -4, and 1 (mod -5) = -4. - dist/Math-BigRat/t/bigratpm.inc: Fix same test case as above. Math::BigRat::bmodinv() only handles integers, and is essentially just a front-end to Math::BigInt::bmodinv().
Diffstat (limited to 'dist/Math-BigRat')
-rw-r--r--dist/Math-BigRat/t/bigratpm.inc2
1 files changed, 1 insertions, 1 deletions
diff --git a/dist/Math-BigRat/t/bigratpm.inc b/dist/Math-BigRat/t/bigratpm.inc
index 13ec6240d8..de5e9e1687 100644
--- a/dist/Math-BigRat/t/bigratpm.inc
+++ b/dist/Math-BigRat/t/bigratpm.inc
@@ -185,13 +185,13 @@ abc:5:NaN
# bmodinv Expected Results from normal use
1:5:1
3:5:2
+3:-5:-3
-2:5:2
8:5033:4404
1234567891:13:6
-1234567891:13:7
324958749843759385732954874325984357439658735983745:2348249874968739:1741662881064902
## bmodinv Error cases / useless use of function
-3:-5:NaN
inf:5:NaN
5:inf:NaN
-inf:5:NaN