X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMath%2FComplex.pm;h=e7a071ab7f162f51420e75f7f2ba4ac9e3848ad6;hb=22d4bb9ccb8701e68f9243547d7e3a3c55f70908;hp=e5434f48d78bf16a9d7fc1fa880f6778b4ca0718;hpb=4b19af017623bfa3bb72bb164598a517f586e0d3;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Math/Complex.pm b/lib/Math/Complex.pm index e5434f4..e7a071a 100644 --- a/lib/Math/Complex.pm +++ b/lib/Math/Complex.pm @@ -7,15 +7,18 @@ package Math::Complex; -$VERSION = "1.30"; - our($VERSION, @ISA, @EXPORT, %EXPORT_TAGS, $Inf); +$VERSION = 1.31; + BEGIN { - my $e = $!; - $Inf = CORE::exp(CORE::exp(30)); # We do want an arithmetic overflow. - $! = $e; # Clear ERANGE. - undef $Inf unless $Inf =~ /^inf(?:inity)?$/i; # Inf INF inf Infinity + unless ($^O eq 'unicosmk') { + my $e = $!; + # We do want an arithmetic overflow. + eval '$Inf = CORE::exp(CORE::exp(30))'; + $! = $e; # Clear ERANGE. + undef $Inf unless $Inf =~ /^inf(?:inity)?$/i; # Inf INF inf Infinity + } $Inf = "Inf" if !defined $Inf || !($Inf > 0); # Desperation. } @@ -1250,23 +1253,15 @@ sub display_format { my %obj = %{$self->{display_format}}; @display_format{keys %obj} = values %obj; } - if (@_ == 1) { - $display_format{style} = shift; - } else { - my %new = @_; - @display_format{keys %new} = values %new; - } - } else { # Called as a class method - if (@_ = 1) { - $display_format{style} = $self; - } else { - my %new = @_; - @display_format{keys %new} = values %new; - } - undef $self; + } + if (@_ == 1) { + $display_format{style} = shift; + } else { + my %new = @_; + @display_format{keys %new} = values %new; } - if (defined $self) { + if (ref $self) { # Called as an object method $self->{display_format} = { %display_format }; return wantarray ? @@ -1274,6 +1269,7 @@ sub display_format { $self->{display_format}->{style}; } + # Called as a class method %DISPLAY_FORMAT = %display_format; return wantarray ? @@ -1393,11 +1389,11 @@ sub stringify_polar { $t -= int(CORE::abs($t) / pit2) * pit2; - if ($format{polar_pretty_print}) { + if ($format{polar_pretty_print} && $t) { my ($a, $b); for $a (2..9) { $b = $t * $a / pi; - if (int($b) == $b) { + if ($b =~ /^-?\d+$/) { $b = $b < 0 ? "-" : "" if CORE::abs($b) == 1; $theta = "${b}pi/$a"; last;