in reply to strange rounding
Anyway, the best way to round to two decimals, is using sprintf:
In case you don't like trailing zeroes (maybe you do), as in "124.00", you can get rid of them using$units = sprintf "%.2f", $units*$p;
turning "123.50" into "123.5", and "124.00" into "124".$units =~ s/\.?0+$//;
Only do this when you know your number contains a decimal point.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: strange rounding
by osunderdog (Deacon) on Nov 29, 2004 at 15:24 UTC |