Skip Menu |

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

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

People
Owner: TELS [...] cpan.org
Requestors: cpan [...] ali.as
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.64
Fixed in: 1.65



Subject: Math::BigFloat::bfloor breaks objects for the value 0.1412024
# Test for bug use Math::BigFloat; my $Number = Math::BigFloat->new( 0.1412024 ); $Number->bfloor; print $Number; __END__ $Number before the bfloor 0 Math::BigFloat=HASH(0x82210c4) '_e' => Math::BigInt=HASH(0x848ee14) '_a' => undef '_f' => 1 '_p' => undef 'sign' => '-' 'value' => ARRAY(0x85d3c3c) 0 7 '_m' => Math::BigInt=HASH(0x85d3bb8) '_a' => undef '_f' => 1 '_p' => undef 'sign' => '+' 'value' => ARRAY(0x85d3be8) 0 1412024 'sign' => '+' $Number after the bfloor 0 Math::BigFloat=HASH(0x82210c4) '_e' => Math::BigInt=HASH(0x848ee14) '_a' => undef '_f' => 1 '_p' => undef 'sign' => '+' 'value' => ARRAY(0x86107c8) 0 0 '_m' => Math::BigInt=HASH(0x85d3bb8) '_a' => undef '_f' => 1 '_p' => undef 'sign' => '+' 'value' => ARRAY(0x85d3be8) empty array 'sign' => '+' As you can see, the mantissa is completely empty, which definately doesn't seem right. As for what's causing it, I'm afraid the code is a little too dense for me. The expected number is, of course, 0 This error occurs in all version posessing bfloor, including the core 5.8.0 distribution. Adam
From: cpan [...] ali.as
OK, this patch should implement a solution for the problem. I also added some tests, and incremented the version numbers. diff -r -u Math-BigInt-1.64.old/lib/Math/BigInt/Calc.pm Math-BigInt-1.64/lib/Math/BigInt/Calc.pm --- Math-BigInt-1.64.old/lib/Math/BigInt/Calc.pm Fri Nov 22 07:30:05 2002 +++ Math-BigInt-1.64/lib/Math/BigInt/Calc.pm Fri Nov 22 08:14:18 2002 @@ -8,7 +8,7 @@ use vars qw/@ISA $VERSION/; @ISA = qw(Exporter); -$VERSION = '0.34'; +$VERSION = '0.35'; # Package to store unsigned big integers in decimal and do math with them @@ -1080,7 +1080,7 @@ my $dst = 0; # destination my $src = _num($c,$y); # as normal int my $xlen = (@$x-1)*$BASE_LEN+length(int($x->[-1])); # len of x in digits - if ($src > $xlen) + if ($src > $xlen or ($src == $xlen and ! defined $x->[1])) { # 12345 67890 shifted right by more than 10 digits => 0 splice (@$x,1); # leave only one element diff -r -u Math-BigInt-1.64.old/lib/Math/BigInt.pm Math-BigInt-1.64/lib/Math/BigInt.pm --- Math-BigInt-1.64.old/lib/Math/BigInt.pm Fri Nov 22 07:30:05 2002 +++ Math-BigInt-1.64/lib/Math/BigInt.pm Fri Nov 22 08:14:03 2002 @@ -18,7 +18,7 @@ my $class = "Math::BigInt"; require 5.005; -$VERSION = '1.64'; +$VERSION = '1.65'; use Exporter; @ISA = qw( Exporter ); @EXPORT_OK = qw( objectify _swap bgcd blcm); Only in Math-BigInt-1.64: pm_to_blib diff -r -u Math-BigInt-1.64.old/t/bare_mbf.t Math-BigInt-1.64/t/bare_mbf.t --- Math-BigInt-1.64.old/t/bare_mbf.t Fri Nov 22 07:30:05 2002 +++ Math-BigInt-1.64/t/bare_mbf.t Fri Nov 22 08:10:21 2002 @@ -27,7 +27,7 @@ } print "# INC = @INC\n"; - plan tests => 1745; + plan tests => 1748; } use Math::BigFloat lib => 'BareCalc'; diff -r -u Math-BigInt-1.64.old/t/bigfltpm.inc Math-BigInt-1.64/t/bigfltpm.inc --- Math-BigInt-1.64.old/t/bigfltpm.inc Fri Nov 22 07:30:05 2002 +++ Math-BigInt-1.64/t/bigfltpm.inc Fri Nov 22 08:07:41 2002 @@ -351,6 +351,7 @@ 0.000000001:0 0.0000000001:0 0.00000000001:0 +0.1234567:0 &finf 1:+:inf 2:-:-inf @@ -1415,6 +1416,7 @@ -51:-51 -51.2:-52 12.2:12 +0.1234567:0 &fceil 0:0 abc:NaN diff -r -u Math-BigInt-1.64.old/t/bigfltpm.t Math-BigInt-1.64/t/bigfltpm.t --- Math-BigInt-1.64.old/t/bigfltpm.t Fri Nov 22 07:30:05 2002 +++ Math-BigInt-1.64/t/bigfltpm.t Fri Nov 22 08:09:34 2002 @@ -26,7 +26,7 @@ } print "# INC = @INC\n"; - plan tests => 1745 + plan tests => 1748 + 2; # own tests } diff -r -u Math-BigInt-1.64.old/t/sub_mbf.t Math-BigInt-1.64/t/sub_mbf.t --- Math-BigInt-1.64.old/t/sub_mbf.t Fri Nov 22 07:30:05 2002 +++ Math-BigInt-1.64/t/sub_mbf.t Fri Nov 22 08:11:53 2002 @@ -26,7 +26,7 @@ } print "# INC = @INC\n"; - plan tests => 1745 + plan tests => 1748 + 6; # + our own tests } diff -r -u Math-BigInt-1.64.old/t/with_sub.t Math-BigInt-1.64/t/with_sub.t --- Math-BigInt-1.64.old/t/with_sub.t Fri Nov 22 07:30:05 2002 +++ Math-BigInt-1.64/t/with_sub.t Fri Nov 22 08:13:18 2002 @@ -28,7 +28,7 @@ } print "# INC = @INC\n"; - plan tests => 1745 + plan tests => 1748 + 1; }
[ADAMK - Thu Nov 21 14:32:30 2002]: Thanx for the test and fix - I hope I can do v1.65 very sooon. Sorry for the delays! Tels Show quoted text
> # Test for bug > use Math::BigFloat; > my $Number = Math::BigFloat->new( 0.1412024 ); > $Number->bfloor; > print $Number; > > __END__
This bug has been fixed in the current release (v1.65). Thank you for your bug report!