Probably the easiest way is to use printf/sprintf:
$unrounded = 0.66666; printf "$unrounded rounded to 3 decimal places is %.3f\n", $unrounded; $rounded = sprintf "%.2f", $a; # rounded to 2 decimal places (0.67)
In reply to Re: How do I print/round a number to a given number of decimal places?
by vroom
in thread How do I print/round a number to a given number of decimal places?
by vroom
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |