<?xml version="1.0" encoding="windows-1252"?>
<node id="961262" title="Is this odd behavior a floating point problem?" created="2012-03-23 12:58:01" updated="2012-03-23 12:58:01">
<type id="115">
perlquestion</type>
<author id="961259">
wickedjester</author>
<data>
<field name="doctext">
&lt;p&gt;Hello!&lt;/p&gt;

&lt;p&gt;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:&lt;/p&gt;

&lt;p&gt;$Avg = 0.001025&lt;/p&gt;

&lt;p&gt;rather than 0.001, which is what it should really return.&lt;/p&gt;

&lt;p&gt;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?&lt;/p&gt;

&lt;p&gt;Many thanks!&lt;/p&gt;</field>
</data>
</node>
