Change 17758 by [EMAIL PROTECTED] on 2002/08/22 22:29:45
bignum-0.12 updates from:
Subject: [ANNOUCNE] Big Math::Big* update
From: Tels <[EMAIL PROTECTED]>
Date: Tue, 13 Aug 2002 22:02:09 +0200 (CEST)
Message-Id: <[EMAIL PROTECTED]>
Affected files ...
.... //depot/perl/MANIFEST#933 edit
.... //depot/perl/lib/bigint.pm#4 edit
.... //depot/perl/lib/bignum.pm#4 edit
.... //depot/perl/lib/bignum/t/bignum.t#3 edit
.... //depot/perl/lib/bignum/t/biinfnan.t#1 add
.... //depot/perl/lib/bignum/t/bn_lite.t#3 add
.... //depot/perl/lib/bignum/t/bninfnan.t#1 add
.... //depot/perl/lib/bignum/t/br_lite.t#3 add
.... //depot/perl/lib/bignum/t/brinfnan.t#1 add
.... //depot/perl/lib/bignum/t/infnan.inc#1 add
.... //depot/perl/lib/bigrat.pm#5 edit
Differences ...
==== //depot/perl/MANIFEST#933 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST#932~17757~ Thu Aug 22 15:19:42 2002
+++ perl/MANIFEST Thu Aug 22 15:29:45 2002
@@ -928,9 +928,15 @@
lib/bigint.pm bignum
lib/bigintpl.t See if bigint.pl works
lib/bignum.pm bignum
+lib/bignum/t/bn_lite.t See if bignum works
+lib/bignum/t/br_lite.t See if bignum works
lib/bignum/t/bigint.t See if bignum works
lib/bignum/t/bignum.t See if bignum works
lib/bignum/t/bigrat.t See if bignum works
+lib/bignum/t/biinfnan.t See if bignum works
+lib/bignum/t/bninfnan.t See if bignum works
+lib/bignum/t/brinfnan.t See if bignum works
+lib/bignum/t/infnan.inc See if bignum works
lib/bignum/t/option_a.t See if bignum works
lib/bignum/t/option_l.t See if bignum works
lib/bignum/t/option_p.t See if bignum works
==== //depot/perl/lib/bigint.pm#4 (text) ====
Index: perl/lib/bigint.pm
--- perl/lib/bigint.pm#3~15523~ Tue Mar 26 11:54:48 2002
+++ perl/lib/bigint.pm Thu Aug 22 15:29:45 2002
@@ -1,10 +1,11 @@
package bigint;
require 5.005;
-$VERSION = '0.02';
+$VERSION = '0.03';
use Exporter;
-@ISA = qw( Exporter );
-@EXPORT_OK = qw( );
+@ISA = qw( Exporter );
+@EXPORT_OK = qw( );
+@EXPORT = qw( inf NaN );
use strict;
use overload;
@@ -179,22 +180,29 @@
# we take care of floating point constants, since BigFloat isn't available
# and BigInt doesn't like them:
overload::constant float => sub { Math::BigInt->new( _constant(shift) ); };
+
+ $self->export_to_level(1,$self,@a); # export inf and NaN
}
+sub inf () { Math::BigInt->binf(); }
+sub NaN () { Math::BigInt->bnan(); }
+
1;
__END__
=head1 NAME
-bigint - Transparent big integer support for Perl
+bigint - Transparent BigInteger support for Perl
=head1 SYNOPSIS
use bignt;
$x = 2 + 4.5,"\n"; # BigInt 6
- print 2 ** 512; # really is what you think it is
+ print 2 ** 512,"\n"; # really is what you think it is
+ print inf + 42,"\n"; # inf
+ print NaN * 7,"\n"; # NaN
=head1 DESCRIPTION
==== //depot/perl/lib/bignum.pm#4 (text) ====
Index: perl/lib/bignum.pm
--- perl/lib/bignum.pm#3~15523~ Tue Mar 26 11:54:48 2002
+++ perl/lib/bignum.pm Thu Aug 22 15:29:45 2002
@@ -1,10 +1,11 @@
package bignum;
require 5.005;
-$VERSION = '0.11';
+$VERSION = '0.12';
use Exporter;
-@ISA = qw( Exporter );
-@EXPORT_OK = qw( );
+@EXPORT_OK = qw( );
+@EXPORT = qw( inf NaN );
+@ISA = qw( Exporter );
use strict;
@@ -166,8 +167,12 @@
print "Math::BigFloat\t\t v$Math::BigFloat::VERSION\n";
exit;
}
+ $self->export_to_level(1,$self,@a); # export inf and NaN
}
+sub inf () { Math::BigInt->binf(); }
+sub NaN () { Math::BigInt->bnan(); }
+
1;
__END__
@@ -181,7 +186,9 @@
use bignum;
$x = 2 + 4.5,"\n"; # BigFloat 6.5
- print 2 ** 512 * 0.1; # really is what you think it is
+ print 2 ** 512 * 0.1,"\n"; # really is what you think it is
+ print inf * inf,"\n"; # prints inf
+ print NaN * 3,"\n"; # prints NaN
=head1 DESCRIPTION
@@ -232,6 +239,29 @@
This prints out the name and version of all modules used and then exits.
perl -Mbignum=v -e ''
+
+=head2 METHODS
+
+Beside import() and AUTOLOAD() there are only a few other methods.
+
+=over 2
+
+=item inf()
+
+A shortcut to return Math::BigInt->binf(). Usefull because Perl does not always
+handle bareword C<inf> properly.
+
+=item NaN()
+
+A shortcut to return Math::BigInt->bnan(). Usefull because Perl does not always
+handle bareword C<NaN> properly.
+
+=item upgrade()
+
+Return the class that numbers are upgraded to, is in fact returning
+C<$Math::BigInt::upgrade>.
+
+=back
=head2 MATH LIBRARY
==== //depot/perl/lib/bignum/t/bignum.t#3 (xtext) ====
Index: perl/lib/bignum/t/bignum.t
--- perl/lib/bignum/t/bignum.t#2~15523~ Tue Mar 26 11:54:48 2002
+++ perl/lib/bignum/t/bignum.t Thu Aug 22 15:29:45 2002
@@ -35,6 +35,8 @@
#ok (2 ** 0.5, 'NaN'); # should be sqrt(2);
+print "huh\n";
+
ok (12->bfac(),479001600);
# see if Math::BigFloat constant works
==== //depot/perl/lib/bignum/t/biinfnan.t#1 (text) ====
Index: perl/lib/bignum/t/biinfnan.t
--- /dev/null Tue May 5 13:32:27 1998
+++ perl/lib/bignum/t/biinfnan.t Thu Aug 22 15:29:45 2002
@@ -0,0 +1,21 @@
+#!/usr/bin/perl -w
+
+###############################################################################
+
+use Test;
+use strict;
+
+BEGIN
+ {
+ $| = 1;
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+ plan tests => 26;
+ }
+
+use bigint;
+
+my ($x);
+
+require "infnan.inc";
+
==== //depot/perl/lib/bignum/t/bn_lite.t#3 (text) ====
Index: perl/lib/bignum/t/bn_lite.t
--- /dev/null Tue May 5 13:32:27 1998
+++ perl/lib/bignum/t/bn_lite.t Thu Aug 22 15:29:45 2002
@@ -0,0 +1,30 @@
+#!/usr/bin/perl -w
+
+###############################################################################
+
+use Test;
+use strict;
+
+BEGIN
+ {
+ $| = 1;
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+ plan tests => 1;
+ }
+
+eval 'require Math::BigInt::Lite;';
+if ($@ eq '')
+ {
+ # can use Lite, so let bignum try it
+ require bignum; bignum->import();
+ # can't get to work a ref(1+1) here, presumable because :constant phase
+ # already done
+ ok ($bignum::_lite,1);
+ }
+else
+ {
+ print "ok 1 # skipped, no Math::BigInt::Lite\n";
+ }
+
+
==== //depot/perl/lib/bignum/t/bninfnan.t#1 (text) ====
Index: perl/lib/bignum/t/bninfnan.t
--- /dev/null Tue May 5 13:32:27 1998
+++ perl/lib/bignum/t/bninfnan.t Thu Aug 22 15:29:45 2002
@@ -0,0 +1,21 @@
+#!/usr/bin/perl -w
+
+###############################################################################
+
+use Test;
+use strict;
+
+BEGIN
+ {
+ $| = 1;
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+ plan tests => 26;
+ }
+
+use bignum;
+
+my ($x);
+
+require "infnan.inc";
+
==== //depot/perl/lib/bignum/t/br_lite.t#3 (text) ====
Index: perl/lib/bignum/t/br_lite.t
--- /dev/null Tue May 5 13:32:27 1998
+++ perl/lib/bignum/t/br_lite.t Thu Aug 22 15:29:45 2002
@@ -0,0 +1,30 @@
+#!/usr/bin/perl -w
+
+###############################################################################
+
+use Test;
+use strict;
+
+BEGIN
+ {
+ $| = 1;
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+ plan tests => 1;
+ }
+
+eval 'require Math::BigInt::Lite;';
+if ($@ eq '')
+ {
+ # can use Lite, so let bignum try it
+ require bigrat; bigrat->import();
+ # can't get to work a ref(1+1) here, presumable because :constant phase
+ # already done
+ ok ($bigrat::_lite,1);
+ }
+else
+ {
+ print "ok 1 # skipped, no Math::BigInt::Lite\n";
+ }
+
+
==== //depot/perl/lib/bignum/t/brinfnan.t#1 (text) ====
Index: perl/lib/bignum/t/brinfnan.t
--- /dev/null Tue May 5 13:32:27 1998
+++ perl/lib/bignum/t/brinfnan.t Thu Aug 22 15:29:45 2002
@@ -0,0 +1,21 @@
+#!/usr/bin/perl -w
+
+###############################################################################
+
+use Test;
+use strict;
+
+BEGIN
+ {
+ $| = 1;
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+ plan tests => 26;
+ }
+
+use bigrat;
+
+my ($x);
+
+require "infnan.inc";
+
==== //depot/perl/lib/bignum/t/infnan.inc#1 (text) ====
Index: perl/lib/bignum/t/infnan.inc
--- /dev/null Tue May 5 13:32:27 1998
+++ perl/lib/bignum/t/infnan.inc Thu Aug 22 15:29:45 2002
@@ -0,0 +1,35 @@
+
+use strict;
+
+my ($x);
+
+###############################################################################
+# inf tests
+
+$x = 1+inf; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'inf');
+$x = 1*inf; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'inf');
+
+# these don't work without exporting inf()
+$x = inf; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'inf');
+$x = inf+inf; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'inf');
+$x = inf*inf; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'inf');
+
+###############################################################################
+# NaN tests
+
+$x = 1+NaN; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+$x = 1*NaN; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+
+# these don't work without exporting NaN()
+$x = NaN; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+$x = NaN+NaN; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+$x = NaN*NaN; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+
+###############################################################################
+# mixed tests
+
+# these don't work without exporting NaN() or inf()
+$x = NaN+inf; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+$x = NaN*inf; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+$x = inf*NaN; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+
==== //depot/perl/lib/bigrat.pm#5 (text) ====
Index: perl/lib/bigrat.pm
--- perl/lib/bigrat.pm#4~15538~ Tue Mar 26 17:13:12 2002
+++ perl/lib/bigrat.pm Thu Aug 22 15:29:45 2002
@@ -1,10 +1,11 @@
package bigrat;
require 5.005;
-$VERSION = '0.04';
+$VERSION = '0.05';
use Exporter;
-@ISA = qw( Exporter );
-@EXPORT_OK = qw( );
+@ISA = qw( Exporter );
+@EXPORT_OK = qw( );
+@EXPORT = qw( inf NaN );
use strict;
@@ -141,15 +142,19 @@
print "Math::BigRat\t\t v$Math::BigRat::VERSION\n";
exit;
}
+ $self->export_to_level(1,$self,@a); # export inf and NaN
}
+sub inf () { Math::BigInt->binf(); }
+sub NaN () { Math::BigInt->bnan(); }
+
1;
__END__
=head1 NAME
-bigrat - Transparent BigNumber/BigRational support for Perl
+bigrat - Transparent BigNumber/BigRationale support for Perl
=head1 SYNOPSIS
End of Patch.