Try to get "Inf" by using &POSIX::HUGE_VAL in sprintf.
authorJarkko Hietaniemi <jhi@iki.fi>
Fri, 28 Apr 2000 13:32:17 +0000 (13:32 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Fri, 28 Apr 2000 13:32:17 +0000 (13:32 +0000)
p4raw-id: //depot/cfgperl@5998

lib/Math/Complex.pm

index 3c4894a..857b8f8 100644 (file)
@@ -5,17 +5,31 @@
 # -- Daniel S. Lewart  Since Sep 1997
 #
 
-require Exporter;
 package Math::Complex;
 
-use 5.005_64;
-use strict;
+$VERSION = "1.30";
+
+our($VERSION, @ISA, @EXPORT, %EXPORT_TAGS, $Inf);
+
+BEGIN {
+    eval { require POSIX; import POSIX 'HUGE_VAL' };
+    if (defined &HUGE_VAL) {
+       $Inf = sprintf "%g", &HUGE_VAL;
+    } else {   
+       my $e = $!;
+       $Inf = CORE::exp(CORE::exp(30));
+       $! = $e; # Clear ERANGE.
+       undef $Inf unless $Inf =~ /^inf$/; # Inf INF inf
+    }
+    $Inf = "Inf" if !defined $Inf || !($Inf > 0);
+}
 
-our($VERSION, @ISA, @EXPORT, %EXPORT_TAGS);
+use strict;
 
-my ( $i, %logn );
+my $i;
+my %LOGN;
 
-$VERSION = sprintf("%s", q$Id: Complex.pm,v 1.26 1998/11/01 00:00:00 dsl Exp $ =~ /(\d+\.\d+)/);
+require Exporter;
 
 @ISA = qw(Exporter);
 
@@ -67,21 +81,10 @@ use overload
 # Package "privates"
 #
 
-my $package        = 'Math::Complex';  # Package name
 my %DISPLAY_FORMAT = ('style' => 'cartesian',
                      'polar_pretty_print' => 1);
 my $eps            = 1e-14;            # Epsilon
 
-my $Inf;
-# Unicos gets a fatal runtime error without -h matherr=errno in ccflags
-unless ($^O eq 'unicos') {
-    my $e = $!;
-    $Inf = CORE::exp(CORE::exp(30));
-    $! = $e; # Clear ERANGE.
-    undef $Inf unless $Inf =~ /^inf$/; # Inf INF inf
-}
-$Inf = "Inf" if !defined $Inf || !$Inf > 0;
-
 #
 # Object attributes (internal):
 #      cartesian       [real, imaginary] -- cartesian form
@@ -766,8 +769,8 @@ sub log10 {
 sub logn {
        my ($z, $n) = @_;
        $z = cplx($z, 0) unless ref $z;
-       my $logn = $logn{$n};
-       $logn = $logn{$n} = CORE::log($n) unless defined $logn; # Cache log(n)
+       my $logn = $LOGN{$n};
+       $logn = $LOGN{$n} = CORE::log($n) unless defined $logn; # Cache log(n)
        return &log($z) / $logn;
 }