diff options
author | Peter John Acklam <pjacklam@online.no> | 2010-11-04 14:22:12 +0100 |
---|---|---|
committer | Florian Ragwitz <rafl@debian.org> | 2010-11-10 12:41:56 +0100 |
commit | 26c6d6546663b8799501bf8dd16374ea8cc4fdd3 (patch) | |
tree | cc452cc6022e2ffb5594004e29b328179030aaf8 /dist/Math-BigInt | |
parent | a3cbd8d01434fbac731fd3f88a8fc77b020787e1 (diff) | |
download | perl-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/Math-BigInt')
-rw-r--r-- | dist/Math-BigInt/lib/Math/BigFloat.pm | 2 | ||||
-rw-r--r-- | dist/Math-BigInt/t/bare_mbf.t | 2 | ||||
-rw-r--r-- | dist/Math-BigInt/t/bigfltpm.inc | 1 | ||||
-rw-r--r-- | dist/Math-BigInt/t/bigfltpm.t | 2 | ||||
-rw-r--r-- | dist/Math-BigInt/t/sub_mbf.t | 2 | ||||
-rw-r--r-- | dist/Math-BigInt/t/with_sub.t | 2 |
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'; |