summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorPeter John Acklam <pjacklam@online.no>2010-11-04 14:22:12 +0100
committerFlorian Ragwitz <rafl@debian.org>2010-11-10 12:41:56 +0100
commit26c6d6546663b8799501bf8dd16374ea8cc4fdd3 (patch)
treecc452cc6022e2ffb5594004e29b328179030aaf8 /dist
parenta3cbd8d01434fbac731fd3f88a8fc77b020787e1 (diff)
downloadperl-26c6d6546663b8799501bf8dd16374ea8cc4fdd3.tar.gz
RT ticket #43694: as_int/as_number lose precision
The as_int/as_number methods lose precision because the wrong library method is used for converting a library integer object to something that is processed by Math::BigInt->new(). The method _num() returns a Perl scalar, with an accuracy limited to the Perl's internal floating point format. The correct is to use _str() which returns a string with all digits preserved. - t/bigfltpm.inc: add test case with more digits than is used in Perl's internal floating point format. - t/bigfltpm.t: increase number of tests by one. - lib/Math/BigFloat.pm: changed library method from _num() to _str().
Diffstat (limited to 'dist')
-rw-r--r--dist/Math-BigInt/lib/Math/BigFloat.pm2
-rw-r--r--dist/Math-BigInt/t/bare_mbf.t2
-rw-r--r--dist/Math-BigInt/t/bigfltpm.inc1
-rw-r--r--dist/Math-BigInt/t/bigfltpm.t2
-rw-r--r--dist/Math-BigInt/t/sub_mbf.t2
-rw-r--r--dist/Math-BigInt/t/with_sub.t2
6 files changed, 6 insertions, 5 deletions
diff --git a/dist/Math-BigInt/lib/Math/BigFloat.pm b/dist/Math-BigInt/lib/Math/BigFloat.pm
index 94aac587e6..53df8e7139 100644
--- a/dist/Math-BigInt/lib/Math/BigFloat.pm
+++ b/dist/Math-BigInt/lib/Math/BigFloat.pm
@@ -3696,7 +3696,7 @@ sub as_number
{
$MBI->_lsft( $z, $x->{_e},10);
}
- $z = Math::BigInt->new( $x->{sign} . $MBI->_num($z));
+ $z = Math::BigInt->new( $x->{sign} . $MBI->_str($z));
$z;
}
diff --git a/dist/Math-BigInt/t/bare_mbf.t b/dist/Math-BigInt/t/bare_mbf.t
index 11b3222ea1..8ecfc9f469 100644
--- a/dist/Math-BigInt/t/bare_mbf.t
+++ b/dist/Math-BigInt/t/bare_mbf.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 2319;
+use Test::More tests => 2320;
BEGIN { unshift @INC, 't'; }
diff --git a/dist/Math-BigInt/t/bigfltpm.inc b/dist/Math-BigInt/t/bigfltpm.inc
index 059ebe1bf9..a27c754a4d 100644
--- a/dist/Math-BigInt/t/bigfltpm.inc
+++ b/dist/Math-BigInt/t/bigfltpm.inc
@@ -590,6 +590,7 @@ fnormNaN:NaN
-inf:-inf
inf:inf
NaN:NaN
+71243225429896467497217836789578596379:71243225429896467497217836789578596379
# test for bug in brsft() not handling cases that return 0
0.000641:0
0.0006412:0
diff --git a/dist/Math-BigInt/t/bigfltpm.t b/dist/Math-BigInt/t/bigfltpm.t
index 042308617a..34fa0f0c69 100644
--- a/dist/Math-BigInt/t/bigfltpm.t
+++ b/dist/Math-BigInt/t/bigfltpm.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 2319
+use Test::More tests => 2320
+ 5; # own tests
diff --git a/dist/Math-BigInt/t/sub_mbf.t b/dist/Math-BigInt/t/sub_mbf.t
index ab7108abec..c556b5c04f 100644
--- a/dist/Math-BigInt/t/sub_mbf.t
+++ b/dist/Math-BigInt/t/sub_mbf.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 2319
+use Test::More tests => 2320
+ 6; # + our own tests
diff --git a/dist/Math-BigInt/t/with_sub.t b/dist/Math-BigInt/t/with_sub.t
index d4baaecb27..97cabab5d2 100644
--- a/dist/Math-BigInt/t/with_sub.t
+++ b/dist/Math-BigInt/t/with_sub.t
@@ -3,7 +3,7 @@
# Test use Math::BigFloat with => 'Math::BigInt::SomeSubclass';
use strict;
-use Test::More tests => 2319 + 1;
+use Test::More tests => 2320 + 1;
use Math::BigFloat with => 'Math::BigInt::Subclass', lib => 'Calc';