"be consistent" | |
PerlMonks |
Rounding with sprintf and -0by johnfl68 (Scribe) |
on Apr 07, 2013 at 01:05 UTC ( [id://1027317]=perlquestion: print w/replies, xml ) | Need Help?? |
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
Back to
Seekers of Perl Wisdom
|
|