title: Perl/mysql floating point imprecision
body: <p>I'm using Perl to communicate floating point numbers with a mysql database. I perform a multiplication in perl:</p>
  
  <pre><code> $var = 0.001 * 3;
  </code></pre>
  
  <p>I then store this value in a  mysql database in a column of type DOUBLE. I later retrieve the result, perform a further multiplication and addition to the number and store it back into the database</p>
  
  <pre><code>$previous_result_from_db += 0.001*1 + 0.001*0.5.
  </code></pre>
  
  <p>The result stored in the database should be <b>0.0045</b>, but instead I get: <b>0.0045000000000000005</b>. I'm trying to understand where the source of the imprecision is. Is it Perl or the database? What is the correct way to handle this kind of floating point interaction to avoid the imprecision?</p>
  
  <p>Thanks!</p>