use Config;
-our($Inf, $ExpInf);
+our ($Inf, $ExpInf);
+our ($vax_float, $has_inf, $has_nan);
+
BEGIN {
- my %DBL_MAX =
+ $vax_float = (pack("d",1) =~ /^[\x80\x10]\x40/);
+ $has_inf = !$vax_float;
+ $has_nan = !$vax_float;
+
+ unless ($has_inf) {
+ # For example in vax, there is no Inf,
+ # and just mentioning the DBL_MAX (1.70141183460469229e+38)
+ # causes SIGFPE.
+
+ # These are pretty useless without a real infinity,
+ # but setting them makes for less warnings about their
+ # undefined values.
+ $Inf = "Inf";
+ $ExpInf = "Inf";
+ return;
+ }
+
+ my %DBL_MAX = # These are IEEE 754 maxima.
(
4 => '1.70141183460469229e+38',
8 => '1.7976931348623157e+308',
12 => '1.1897314953572317650857593266280070162E+4932',
16 => '1.1897314953572317650857593266280070162E+4932',
);
+
my $nvsize = $Config{nvsize} ||
($Config{uselongdouble} && $Config{longdblsize}) ||
$Config{doublesize};
if ($^O eq 'unicosmk') {
$Inf = $DBL_MAX;
} else {
- local $SIG{FPE} = { };
+ local $SIG{FPE} = sub { };
local $!;
# We do want an arithmetic overflow, Inf INF inf Infinity.
for my $t (
$Inf = $i;
last;
}
- }
+ }
$Inf = $DBL_MAX unless defined $Inf; # Oh well, close enough.
die "Math::Complex: Could not get Infinity"
unless $Inf > $BIGGER_THAN_THIS;
- $ExpInf = exp(99999);
- }
+ $ExpInf = eval 'exp(99999)';
+ }
# print "# On this machine, Inf = '$Inf'\n";
}
if (defined $p) {
$p =~ s/^\+//;
- $p =~ s/^(-?)inf$/"${1}9**9**9"/e;
+ $p =~ s/^(-?)inf$/"${1}9**9**9"/e if $has_inf;
$q =~ s/^\+//;
- $q =~ s/^(-?)inf$/"${1}9**9**9"/e;
+ $q =~ s/^(-?)inf$/"${1}9**9**9"/e if $has_inf;
}
return ($p, $q);
if (defined $p) {
$p =~ s/^\+//;
$q =~ s/^\+//;
- $p =~ s/^(-?)inf$/"${1}9**9**9"/e;
- $q =~ s/^(-?)inf$/"${1}9**9**9"/e;
+ $p =~ s/^(-?)inf$/"${1}9**9**9"/e if $has_inf;
+ $q =~ s/^(-?)inf$/"${1}9**9**9"/e if $has_inf;
}
return ($p, $q);