Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Negative zero? There's gotta be a sprintf that undoes that, right?

by duckyd (Hermit)
on Dec 12, 2007 at 02:30 UTC ( [id://656538] : note . print w/replies, xml ) Need Help??


in reply to Re: Negative zero? There's gotta be a sprintf that undoes that, right?
in thread Negative zero? There's gotta be a sprintf that undoes that, right?

This doesn't work for me, perl 5.8.6 on OS X, however with a little change it does:
for ( -0.1, -0.01, -0.001, -0.0001, -0.00001, -10, ) { my $num = sprintf "%0.1f", $_; $num = abs( $num ) if $num == 0; printf "%s --> %0.1f\n", $_, $num; }
  • Comment on Re^2: Negative zero? There's gotta be a sprintf that undoes that, right?
  • Download Code