title: SQL evaluating loop condition wrong
body: <p>Part of one of my UDFs has a section that tries to find the number of decimal places after a float and returns the number multiplied up by powers of 10 such that it's an integer. Using 1.0005 as an example, here's the segment:</p>
  
  <pre><code>DECLARE @num FLOAT = 1.0005
  DECLARE @exponent AS INT = 0
  
  WHILE @num - FLOOR(@num) &gt; 0.000001
  BEGIN
  SET @exponent += 1
  SET @num *= 10
  END
  </code></pre>
  
  <p>When I debug this in SSMS 2012, on the 'while' line if I evaluate <code>? CASE WHEN @num - FLOOR(@num) &gt; 0.000001 THEN 1 ELSE 0 END</code> in the immediate window on its fourth iteration onwards I get 0 - however, the loop keeps running indefinitely.</p>
  
  <p>Any ideas?</p>