Skip Menu |

This queue is for tickets about the Math-BigInt-Pari CPAN distribution.

Report information
The Basics
Id: 80126
Status: resolved
Priority: 0/
Queue: Math-BigInt-Pari

People
Owner: Nobody in particular
Requestors: bko [...] bko.to
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.17
Fixed in: (no value)



Subject: 0->bmodpow always return 1
In fact, modpow of zero is always zero. However bmodpow of Math::BigInt::Pari always return 1. # test script use Math::BigInt (lib => 'Pari'); my $a = Math::BigInt->bzero(); my $b = new Math::BigInt("12345678901234567890"); my $n = new Math::BigInt("65537"); my $c = $a->copy()->bmodpow($b,$n); print "$a->modpow($b,$n)=$c\n"; # the result 0->modpow(12345678901234567890,65537)=1 _modpow in Math::BigInt::Pari.pm should be modified as follows: sub _modpow { # modulus of power ($x ** $y) % $z my ($c,$num,$exp,$mod) = @_; # in the trivial case, if (gcmp1($mod)) -> if (gcmp1($mod) || gcmp0($num)) { $num = PARI(0); return $num; } if (gcmp1($num) || gcmp0($num)) -> if (gcmp1($num)) { $num = PARI(1); return $num; }