title: MS SQL Float Decimal Comparison Problems
body: <p>I'm in the process of normalising a database, and part of this involves converting a column from one table from a <code>FLOAT</code> to a <code>DECIMAL(28,18)</code>.  When I then try to join this converted column back to the source column, it returns no results in some cases.</p>
  
  <p>It seems to bee something to do with the ways its converted.  For example, the  <code>FLOAT</code> converted to a <code>DECIMAL(28,18)</code> produces:</p>
  
  <pre><code>51.051643260000006000
  </code></pre>
  
  <p>The original <code>FLOAT</code> is </p>
  
  <pre><code>51.05164326
  </code></pre>
  
  <p>I have tried various ways of modifying the <code>FLOAT</code>, and none of these work either:</p>
  
  <pre><code>CAST(51.05164326 AS DECIMAL(28,18)) = 51.051643260000000000
  STR(51.05164326 , 28,18) = 51.0516432599999990
  </code></pre>
  
  <p>The reason for the conversion is due to improving the accuracy of these fields.</p>
  
  <p>Has anyone got a consistent strategy to convert these numbers, and be able to ensure subsequent joins work?</p>
  
  <p>Thanks in advance</p>
  
  <p>CM</p>