summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChip Salzenberg <chip@perl.com>1994-10-19 04:35:28 +1200
committerChip Salzenberg <chip@atlantic.net>1997-04-03 10:03:25 +1200
commitafea815c58c54233979716dd5770b69df2df51f8 (patch)
treebf6107a8d7d46c38e2126db0a1112a932449670b
parent34d04c8d9a0f251c651e2f9860ac3ffc476d363d (diff)
downloadperl-afea815c58c54233979716dd5770b69df2df51f8.tar.gz
Don't use $4 when it might be undef
-rw-r--r--lib/bigfloat.pl6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/bigfloat.pl b/lib/bigfloat.pl
index 9ad171f295..d687c784f1 100644
--- a/lib/bigfloat.pl
+++ b/lib/bigfloat.pl
@@ -41,8 +41,10 @@ $rnd_mode = 'even';
sub main'fnorm { #(string) return fnum_str
local($_) = @_;
s/\s+//g; # strip white space
- if (/^([+-]?)(\d*)(\.(\d*))?([Ee]([+-]?\d+))?$/ && "$2$4" ne '') {
- &norm(($1 ? "$1$2$4" : "+$2$4"),(($4 ne '') ? $6-length($4) : $6));
+ if (/^([+-]?)(\d*)(\.(\d*))?([Ee]([+-]?\d+))?$/
+ && ($2 ne '' || defined($4))) {
+ my $x = defined($4) ? $4 : '';
+ &norm(($1 ? "$1$2$x" : "+$2$x"), (($x ne '') ? $6-length($x) : $6));
} else {
'NaN';
}