my $sign = ""; my $number = -0.000001; my $example = sprintf("%.5f", $number); #$example = $number; #uncomment this, to remove the initial rounding print "A. Started with : $example \n"; if ($example < 0) { $example = -$example; $sign = "-"; print "B. Less than zero: changed to $example \n"; } print "C. the number is $example \n"; if ($example == 0 ) { print "D1. the number ($example) is equal to zero, removing the sign.\n"; $example *= -1; #(couldn't hurt, it's zero) print "D2. the number ($example) is equal to zero, removing the sign.\n"; $sign = ''; } print "E. proceeding to sprint $example with sign $sign .\n"; $tret = sprintf("rounded float: %s%7.5f : unrounded %7.5f", $sign, $example, $number); print "$tret \n";