title: TSQL - make a literal float value
body: <p>I understand the host of issues in comparing floats, and lament their use in this case - but I'm not the table author and have only a small hurdle to climb...</p>
  
  <p>Someone has decided to use floats as you'd expect GUIDs to be used.  I need to retrieve all the records with a specific float value.</p>
  
  <pre><code>sp_help MyTable
  
  -- Column_name  Type    Computed    Length  Prec
  -- RandomGrouping   float   no  8   53   
  </code></pre>
  
  <p>Here's my naive attempt:</p>
  
  <pre><code>--yields no results
  SELECT RandomGrouping
  FROM MyTable
  WHERE RandomGrouping = 0.867153569942739
  </code></pre>
  
  <p>And here's an approximately working attempt:</p>
  
  <pre><code>--yields 2 records
  SELECT RandomGrouping
  FROM MyTable
  WHERE RandomGrouping BETWEEN 0.867153569942739 - 0.00000001
        AND 0.867153569942739 + 0.00000001
  
  --  0.867153569942739
  --  0.867153569942739
  </code></pre>
  
  <p>In my naive attempt, is that literal a floating point literal?  Or is it really a decimal literal that gets converted later?</p>
  
  <p>If my literal is not a floating point literal, what is the syntax for making a floating point literal?</p>
  
  <p>EDIT: Another possibility has occurred to me...  it may be that a more precise number than is displayed is stored in this column.  It may be impossible to create a literal that represents this number.  I will accept answers that demonstrate that this is the case.</p>
  
  <hr>
  
  <p>EDIT: response to DVK.</p>
  
  <p>TSQL is MSSQLServer's dialect of SQL.</p>
  
  <p>This script works, and so equality can be performed deterministically between float types:</p>
  
  <pre><code>DECLARE @X float
  SELECT top 1 @X = RandomGrouping
  FROM MyTable
  WHERE RandomGrouping BETWEEN 0.839110948199148 - 0.000000000001
    AND 0.839110948199148 + 0.000000000001
    --yields two records
  SELECT *
  FROM MyTable
  WHERE RandomGrouping = @X
  </code></pre>
  
  <p>I said "approximately" because that method tests for a range.  With that method I could get values that are not equal to my intended value.</p>
  
  <p>The linked article doesn't apply because I'm not (intentionally) trying to straddle the world boundaries between decimal and float.  I'm trying to work with only floats.  This isn't about the non-convertibility of decimals to floats.</p>
  
  <hr>
  
  <p>Response to Zinglon:</p>
  
  <p>A literal value that can find my records, thanks.</p>
  
  <pre><code>DECLARE @Y binary(8)
  SET @Y = 0x3FEAD9FF34076378
  
  SELECT *
  FROM MyTable
  WHERE convert(binary(8), RandomGrouping) = @Y
  </code></pre>