diff options
author | M. J. T. Guy <mjtg@cus.cam.ac.uk> | 1998-07-24 19:29:53 +0100 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-07-26 02:03:01 +0000 |
commit | e3c7ef20866011e0e98de5b78863094f34fd2bd6 (patch) | |
tree | eb0effbd52941e500472df7f36ff4aca8e5d2225 /lib/Math | |
parent | 731da2878475fb47e9cdf65e54a2c72c4e8e3c26 (diff) | |
download | perl-e3c7ef20866011e0e98de5b78863094f34fd2bd6.tar.gz |
fix behavior of <=> on bigints
Message-Id: <E0yzlfF-0004kz-00@taurus.cus.cam.ac.uk>
Subject: [PATCH] Re: Math::BigInt <=> op is not correct.
p4raw-id: //depot/maint-5.005/perl@1652
Diffstat (limited to 'lib/Math')
-rw-r--r-- | lib/Math/BigInt.pm | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/Math/BigInt.pm b/lib/Math/BigInt.pm index bbd15e4a88..ef4af613c3 100644 --- a/lib/Math/BigInt.pm +++ b/lib/Math/BigInt.pm @@ -82,8 +82,8 @@ sub external { #(int_num_array) return num_str # Negate input value. sub bneg { #(num_str) return num_str local($_) = &bnorm(@_); - vec($_,0,8) ^= ord('+') ^ ord('-') unless $_ eq '+0'; - s/^H/N/; + return $_ if $_ eq '+0' or $_ eq 'NaN'; + vec($_,0,8) ^= ord('+') ^ ord('-'); $_; } @@ -106,7 +106,7 @@ sub bcmp { #(num_str, num_str) return cond_code } elsif ($y eq 'NaN') { undef; } else { - &cmp($x,$y); + &cmp($x,$y) <=> 0; } } @@ -393,7 +393,7 @@ are not numbers, as well as the result of dividing by zero. =head1 Autocreating constants After C<use Math::BigInt ':constant'> all the integer decimal constants -in the given scope are converted to C<Math::BigInt>. This convertion +in the given scope are converted to C<Math::BigInt>. This conversion happens at compile time. In particular |