Skip Menu |

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

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

People
Owner: TELS [...] cpan.org
Requestors: gak-a [...] web.de
Cc:
AdminCc:

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



Subject: Can't use an undefined value as an ARRAY reference
Date: Thu, 15 Feb 2007 14:00:12 +0100
To: <bug-Math-BigInt [...] rt.cpan.org>
From: "GAK" <gak-a [...] web.de>
When I use Math:BigInt, the following perl code results in an error: sub log2{ my $n = shift; return log($n)/log(2); } Error: "Can't use an undefined value as an ARRAY reference at /usr/lib/perl5/5.8.8/Math/BigInt/Calc.pm line 1338." The same error also shows up if I use the Math::Complex logn function instead. I use Perl version: v5.8.8 on a GNU/Linux system.
On Thu Feb 15 08:02:38 2007, gak-a@web.de wrote: Show quoted text
> When I use Math:BigInt, the following perl code results in an error: > > sub log2{ > my $n = shift; > return log($n)/log(2); > } > > Error: "Can't use an undefined value as an ARRAY reference at > /usr/lib/perl5/5.8.8/Math/BigInt/Calc.pm line 1338." > > The same error also shows up if I use the Math::Complex logn function > instead. > > I use Perl version: v5.8.8 on a GNU/Linux system. >
I have fixed this bug and it will be in Math::BigInt v1.80. However, some notes: under "use Math::BigInt;", log(2) will be a plain Perl scalar, unless you use "bignum". log(Math::BigInt->new(288)) will result in a BigInt, e.g. a truncated result log(Math::BigInt->new(288))/log(2) will result in inf, since log(2) is about 0.6, and this is, when converted into a BigInt, simple truncated 0. If you want to calcuate big logarithms, then you need to use Math::BigFloat: te@linux:~/perl/math/Math-BigInt-1.80> perl -Ilib log.pl Inside log2: 5.66296048013595 0.693147180559945 8.16992500144231 Inside log2: 5 0.693147180559945 inf Inside log2: 5.662960480135945929876651081135934249672 0.693147180559945 8.16992500144231600991874978552459796636 te@linux:~/perl/math/Math-BigInt-1.80> cat log.pl use Math::BigInt; use Math::BigFloat; print log2(288), "\n"; print log2(Math::BigInt->new(288)), "\n"; print log2(Math::BigFloat->new(288)), "\n"; sub log2{ my $n = shift; print "Inside log2: ", log($n), " ", log(2), "\n"; return log($n) / log(2); } Thank you for your report!
I just released Math::BigInt 1.80 to CPAN, which fixes this issue. Thank you for your report, and sorry for the long delay.