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

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

Hello!

I've got an array with 40 elements with each element having a value of '0.001'. If I add them all together and divide by 40 to get the average, I get something like:

$Avg = 0.001025

rather than 0.001, which is what it should really return.

Now, the script I'm righting is a chemical diffusion model dealing with very small numbers and this kind of inaccuracy is causing me problems. If this is a floating point issue, can anyone give me a recommendation on how to deal with this?

Many thanks!