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


in reply to Rounding

See perlfaq4 for why this happens, decimal fractions are not exactly representable in binary.

What you want is called banker's round. It tends to minimize cumulative errors, as well as giving a useful surplus of even numbers.

After Compline,
Zaxo