johnfl68 has asked for the wisdom of the Perl Monks concerning the following question:
Hello:
I am using sprintf to round temperatures.
my $temperature = sprintf("%.0f", $temperature);Nothing fancy, and it works fine for what I want, with one exception.
If the temperature is greater than -0.50 but less than 0.00, using sprintf gives -0, but I want just 0.
Right now I just added a if/then to change -0 to 0, but is there a simpler way?
So far in looking I have not found anything, but then some of you know some little tricks, so I figure it doesn't hurt to ask.
Thanks!
John
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Rounding with sprintf and -0
by Loops (Curate) on Apr 07, 2013 at 02:04 UTC | |
|
Re: Rounding with sprintf and -0
by Anonymous Monk on Apr 07, 2013 at 01:41 UTC | |
by johnfl68 (Scribe) on Apr 07, 2013 at 03:03 UTC | |
|
Re: Rounding with sprintf and -0
by Khen1950fx (Canon) on Apr 07, 2013 at 06:55 UTC | |
by Anonymous Monk on Apr 07, 2013 at 07:17 UTC |