Skip Menu |

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

Report information
The Basics
Id: 12849
Status: resolved
Worked: 8 min
Priority: 0/
Queue: Math-BigInt

People
Owner: TELS [...] cpan.org
Requestors: jameshippisley [...] yahoo.com
Cc:
AdminCc:

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



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
[guest - Mon May 16 20:39:46 2005]: Show quoted text
> 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'". >
Moin, I can recreate the problem on my machine using Perl 5.8.6 and Math::BigInt v1.76. I'll try to debug this and post an update ASAP. Thanx for the report! Tels
That bug should now be fixed in v1.77 - the shortcut in Calc for dividing numbers of the same lenght was simple wrong. I removed it and added a testcase. Thanx for your report!