diff options
author | Larry Wall <lwall@netlabs.com> | 1995-03-12 22:32:14 -0800 |
---|---|---|
committer | Larry Wall <lwall@netlabs.com> | 1995-03-12 22:32:14 -0800 |
commit | 748a93069b3d16374a9859d1456065dd3ae11394 (patch) | |
tree | 308ca14de9933a313dceacce8be77db67d9368c7 /lib/Math | |
parent | fec02dd38faf8f83471b031857d89cb76fea1ca0 (diff) | |
download | perl-748a93069b3d16374a9859d1456065dd3ae11394.tar.gz |
Perl 5.001perl-5.001
[See the Changes file for a list of changes]
Diffstat (limited to 'lib/Math')
-rw-r--r-- | lib/Math/BigInt.pm | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/Math/BigInt.pm b/lib/Math/BigInt.pm index 3e0fc17ff6..8c0ca4e6d4 100644 --- a/lib/Math/BigInt.pm +++ b/lib/Math/BigInt.pm @@ -2,32 +2,34 @@ package Math::BigInt; %OVERLOAD = ( # Anonymous subroutines: -'+' => sub {new BigInt &badd}, -'-' => sub {new BigInt +'+' => sub {new Math::BigInt &badd}, +'-' => sub {new Math::BigInt $_[2]? bsub($_[1],${$_[0]}) : bsub(${$_[0]},$_[1])}, -'<=>' => sub {new BigInt +'<=>' => sub {new Math::BigInt $_[2]? bcmp($_[1],${$_[0]}) : bcmp(${$_[0]},$_[1])}, -'cmp' => sub {new BigInt +'cmp' => sub {new Math::BigInt $_[2]? ($_[1] cmp ${$_[0]}) : (${$_[0]} cmp $_[1])}, -'*' => sub {new BigInt &bmul}, -'/' => sub {new BigInt +'*' => sub {new Math::BigInt &bmul}, +'/' => sub {new Math::BigInt $_[2]? scalar bdiv($_[1],${$_[0]}) : scalar bdiv(${$_[0]},$_[1])}, -'%' => sub {new BigInt +'%' => sub {new Math::BigInt $_[2]? bmod($_[1],${$_[0]}) : bmod(${$_[0]},$_[1])}, -'**' => sub {new BigInt +'**' => sub {new Math::BigInt $_[2]? bpow($_[1],${$_[0]}) : bpow(${$_[0]},$_[1])}, -'neg' => sub {new BigInt &bneg}, -'abs' => sub {new BigInt &babs}, +'neg' => sub {new Math::BigInt &bneg}, +'abs' => sub {new Math::BigInt &babs}, qw( "" stringify 0+ numify) # Order of arguments unsignificant ); +$NaNOK=1; + sub new { my $foo = bnorm($_[1]); - die "Not a number initialized to BigInt" if $foo eq "NaN"; + die "Not a number initialized to Math::BigInt" if !$NaNOK && $foo eq "NaN"; bless \$foo; } sub stringify { "${$_[0]}" } |