summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Peters <steve@fisharerojo.org>2007-04-10 02:18:24 +0000
committerSteve Peters <steve@fisharerojo.org>2007-04-10 02:18:24 +0000
commitbce280147cab576cf18d8ed362df18f471c16952 (patch)
tree47bfe5cab1cc81a04e3092bf10bdf81aefc740b1 /lib
parent7d193e396ed9e1516565a568311b86ae5b3466a3 (diff)
downloadperl-bce280147cab576cf18d8ed362df18f471c16952.tar.gz
Upgrade to bignum-0.20 and Math-BigRat-0.18.
p4raw-id: //depot/perl@30877
Diffstat (limited to 'lib')
-rw-r--r--lib/Math/BigRat.pm2
-rw-r--r--lib/bignum.pm3
-rw-r--r--lib/bignum/t/bigexp.t26
3 files changed, 29 insertions, 2 deletions
diff --git a/lib/Math/BigRat.pm b/lib/Math/BigRat.pm
index c4c131bacc..4668197172 100644
--- a/lib/Math/BigRat.pm
+++ b/lib/Math/BigRat.pm
@@ -23,7 +23,7 @@ use vars qw($VERSION @ISA $upgrade $downgrade
@ISA = qw(Math::BigFloat);
-$VERSION = '0.17';
+$VERSION = '0.18';
use overload; # inherit overload from Math::BigFloat
diff --git a/lib/bignum.pm b/lib/bignum.pm
index 7796d47af3..a6daee51b8 100644
--- a/lib/bignum.pm
+++ b/lib/bignum.pm
@@ -1,7 +1,7 @@
package bignum;
use 5.006002;
-$VERSION = '0.19';
+$VERSION = '0.20';
use Exporter;
@EXPORT_OK = qw( );
@EXPORT = qw( inf NaN );
@@ -492,6 +492,7 @@ Some cool command line examples to impress the Python crowd ;)
perl -Mbignum -le 'print 3/7 + 5/7 + 8/3'
perl -Mbignum -le 'print 123->is_odd()'
perl -Mbignum -le 'print log(2)'
+ perl -Mbignum -le 'print exp(1)'
perl -Mbignum -le 'print 2 ** 0.5'
perl -Mbignum=a,65 -le 'print 2 ** 0.2'
perl -Mbignum=a,65,l,GMP -le 'print 7 ** 7777'
diff --git a/lib/bignum/t/bigexp.t b/lib/bignum/t/bigexp.t
new file mode 100644
index 0000000000..2fc631fff1
--- /dev/null
+++ b/lib/bignum/t/bigexp.t
@@ -0,0 +1,26 @@
+#!/usr/bin/perl -w
+
+###############################################################################
+# test for bug #18025: bignum/bigrat can lead to a number that is both 1 and 0
+
+use Test::More;
+use strict;
+
+BEGIN
+ {
+ $| = 1;
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+ plan tests => 4;
+ }
+
+use bignum;
+
+my $lnev = -7 / (10**17);
+my $ev=exp($lnev);
+
+is( sprintf('%0.5f',$ev) , '1.00000', '($ev) is approx. 1' );
+is( sprintf('%0.5f',1-$ev) , '0.00000', '(1-$ev) is approx. 0' );
+is( sprintf('%0.5f',1-"$ev") , '0.00000', '(1-"$ev") is approx. 0' );
+
+cmp_ok( $ev, '!=', 0, '$ev should not equal 0');