Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I faced an issue in printf which is weird If i give $unrounded="7.425" result is 7.42 and if $unrounded="8.425" the result is 8.43 Anyone here to help me...
  • Comment on How do I print/round a number to a given number of decimal places?

Replies are listed 'Best First'.
Re^2: Answer: How do I print/round a number to a given number of decimal places?
by choroba (Cardinal) on Mar 29, 2012 at 12:41 UTC
Re^2: Answer: How do I print/round a number to a given number of decimal places?
by tangent (Parson) on Mar 29, 2012 at 17:14 UTC
    I have worked around this problem by doing this before calling printf:
    $number += 0.001 if $number =~ m/\.\d{2}5$/;