From: Steve Peters Date: Tue, 10 Apr 2007 02:18:24 +0000 (+0000) Subject: Upgrade to bignum-0.20 and Math-BigRat-0.18. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bce280147cab576cf18d8ed362df18f471c16952;p=p5sagit%2Fp5-mst-13.2.git Upgrade to bignum-0.20 and Math-BigRat-0.18. p4raw-id: //depot/perl@30877 --- diff --git a/MANIFEST b/MANIFEST index ef24ca4..e5dbe45 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1471,6 +1471,7 @@ lib/bigint.pl An arbitrary precision integer arithmetic package lib/bigintpl.t See if bigint.pl works lib/bigint.pm bignum lib/bignum.pm bignum +lib/bignum/t/bigexp.t See if bignum works lib/bignum/t/bigint.t See if bigint works lib/bignum/t/bignum.t See if bignum works lib/bignum/t/bigrat.t See if bigrat works diff --git a/lib/Math/BigRat.pm b/lib/Math/BigRat.pm index c4c131b..4668197 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 7796d47..a6daee5 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 0000000..2fc631f --- /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');