fix behavior of <=> on bigints
[p5sagit/p5-mst-13.2.git] / lib / Math / BigInt.pm
index bbd15e4..ef4af61 100644 (file)
@@ -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