http://www.perlmonks.org?node_id=804204

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

Was looking out for the rounding convention used by perl sprintf in-built function. I was thinking that it does a normal rounding (ROUND_HALF_UP - in Java's rounding mode convention - http://www.j2ee.me/javase/6/docs/api/java/math/RoundingMode.html), but the digging up further proved to be wrong. >> /usr/local/bin/perl5.10.1 -e 'print(sprintf("%.2f", shift @ARGV)."\n");' 0.335 0.34 >> /usr/local/bin/perl5.10.1 -e 'print(sprintf("%.2f", shift @ARGV)."\n");' 1.335 1.33