in reply to Re^4: 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?
I was hoping || would work, cuz then you could do$num = '-0.0000009'; $num = sprintf("%7.5f",$num); $num = $num == 0 ? '0.00000' : $num; print "$num\n";
but alas, no. The following works...$num = sprintf("%7.5f",$num) || '0.00000';
but you lose all trailing zeros, which works if you only want to round, but not for formatting, so probably doesn't help.$num = sprintf("%7.5f",$num)+0 || '0.00000';
|
|---|