Subject: | bdiv using Math::BigInt::Calc gives incorrect value |
Hi!
The following code shows $a->bdiv($b) yielding 1 when $a<$b. The same code works fine when I do "use Math::BigInt lib => 'GMP'".
#!/usr/local/bin/perl5.8.6
use Math::BigInt;
foreach ("","::Calc") {
my $pkg = "Math::BigInt$_\::VERSION";
print "$pkg version is ", ${$pkg},"\n";
}
foreach my $i (0..100) {
my $pow2 = new Math::BigInt(2)->bpow($i);
my $pow2sub1 = $pow2->copy->bdec;
my $ratio = $pow2sub1->copy->bdiv($pow2);
$ratio != 0 and die "ERROR: (2^$i-1)/(2^$i) computed as $ratio\n";
}
output...
Math::BigInt::VERSION version is 1.76
Math::BigInt::Calc::VERSION version is 0.46
ERROR: (2^24-1)/(2^24) computed as 1
I am using a recently installed perl5.8.6 built on a machine running rh linux 7.2. I am seeing similar (presumably related) effects with brsft on large numbers.
Any assistance appreciated!
Thanks,
James