in reply to Negative zero? There's gotta be a sprintf that undoes that, right?
The sub can be written golfier, if you like:sub remove_sign_on_zero { my $num_str = shift; if ($num_str =~ /^-([0\.]+)$/) { return " $1"; } else { return $num_str; } } my $num = remove_sign_on_zero( sprintf('%7.5f', $example) );
sub remove_sign_on_zero { $_[0]=~/^-([0\.]+)$/ ? " $1" : $_[0] }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Negative zero? There's gotta be a sprintf that undoes that, right?
by suaveant (Parson) on Dec 12, 2007 at 15:13 UTC |