$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)