in reply to How do I print/round a number to a given number of decimal places?

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)
  • Comment on Re: How do I print/round a number to a given number of decimal places?
  • Download Code

Replies are listed 'Best First'.