title: SQL Server Float data type calculation vs decimal
body: <p>In the following query</p>
  
  <pre><code>declare @a float(23)
  declare @b float(23)
  declare @c float(53)
  set @a = 123456789012.1234
  set @b = 1234567.12345678
  set @c = @a * @b
  select @c
  
  select LTRIM(STR((@c),32,12))
  
  declare @x  decimal(16,4)
  declare @y decimal(16,8)
  declare @z decimal (32,12)
  
  set @x = 123456789012.1234
  set @y = 1234567.12345678
  set @z = @x * @y
  select @z
  </code></pre>
  
  <p>I get answers as </p>
  
  <pre><code>1.52415693411713E+17
  152415693411713020.000000000000
  152415692881907790.143935926652
  </code></pre>
  
  <p>From the above answers the third answer is the correct one. Is this the reason why float data type is called Approximate Numeric Data Type</p>
  
  <p>Or am I doing something fundamentally wrong.</p>
  
  <p>BTW this is due to a problem I have with legacy system wherein I have to use float as storage data type, at the same time in there should not be loss of precision while calculation.</p>
  
  <p>Please suggest alternatives, or an explanation. </p>