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
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;
# 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
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;
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__
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
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
Math with the numbers is done (by default) by a module called
#ok (2 ** 0.5, 'NaN'); # should be sqrt(2);
+print "huh\n";
+
ok (12->bfac(),479001600);
# see if Math::BigFloat constant works
--- /dev/null
+#!/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";
+
--- /dev/null
+#!/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";
+ }
+
+
--- /dev/null
+#!/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";
+
--- /dev/null
+#!/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";
+ }
+
+
--- /dev/null
+#!/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";
+
--- /dev/null
+
+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');
+
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;
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