[PATCH bleadperl] Math::Big* doc patches (and some code)
[p5sagit/p5-mst-13.2.git] / lib / Math / Complex.pm
index e7a071a..4634d0f 100644 (file)
@@ -9,15 +9,25 @@ package Math::Complex;
 
 our($VERSION, @ISA, @EXPORT, %EXPORT_TAGS, $Inf);
 
-$VERSION = 1.31;
+$VERSION = 1.32;
 
 BEGIN {
     unless ($^O eq 'unicosmk') {
         my $e = $!;
-       # We do want an arithmetic overflow.
-        eval '$Inf = CORE::exp(CORE::exp(30))';
+       # We do want an arithmetic overflow, Inf INF inf Infinity:.
+        undef $Inf unless eval <<'EOE' and $Inf =~ /^inf(?:inity)?$/i;
+         local $SIG{FPE} = sub {die};
+         my $t = CORE::exp 30;
+         $Inf = CORE::exp $t;
+EOE
+       if (!defined $Inf) {            # Try a different method
+         undef $Inf unless eval <<'EOE' and $Inf =~ /^inf(?:inity)?$/i;
+           local $SIG{FPE} = sub {die};
+           my $t = 1;
+           $Inf = $t + "1e99999999999999999999999999999999";
+EOE
+       }
         $! = $e; # Clear ERANGE.
-        undef $Inf unless $Inf =~ /^inf(?:inity)?$/i; # Inf INF inf Infinity
     }
     $Inf = "Inf" if !defined $Inf || !($Inf > 0); # Desperation.
 }
@@ -664,7 +674,7 @@ sub Re {
 #
 sub Im {
        my ($z, $Im) = @_;
-       return $z unless ref $z;
+       return 0 unless ref $z;
        if (defined $Im) {
            $z->{'cartesian'} = [ ${$z->cartesian}[0], $Im ];
            $z->{c_dirty} = 0;
@@ -1414,6 +1424,8 @@ sub stringify_polar {
 1;
 __END__
 
+=pod
+
 =head1 NAME
 
 Math::Complex - complex numbers and associated mathematical functions