title: An invalid floating point operation occurred. SQL Server 2008
body: <p>I have weird problem with this code: if I run it like shown below I get error:</p>
  
  <blockquote>
    <p><strong>An invalid floating point operation occurred.</strong></p>
  </blockquote>
  
  <p>But if I change parameter <code>@Longitude</code> to -98.508730 <strong>(<em>notice only last digit changed</em>)</strong> code works just fine. </p>
  
  <p>The code is supposed to lists properties in <code>@MilesRadius</code> around some LatLng point.<br>
  @Latitude and @Longitude parameters are of the same type as longitude and latitude fields in table Address.</p>
  
  <p>What can I do here? Thanks.</p>
  
  <pre><code>DECLARE @Latitude decimal (10,6);
  DECLARE @Longitude decimal (10,6);
  DECLARE @MilesRadius int;
  SET @Latitude = 29.607654
  SET @Longitude = -98.508731
  SET @MilesRadius  = 5
  
  SELECT     ADR.LineOne as address, 
             ADR.City as city,           
             ADR.Latitude as latitude,
             ADR.Longitude as longitude, 
             ((3959 * acos(cos(radians(@Latitude)) * cos(radians(ADR.Latitude)) * cos(radians(ADR.Longitude) - radians(@Longitude)) + sin(radians(@Latitude)) * sin(radians(ADR.Latitude))))) as distance
  FROM       Shared.Address ADR
  WHERE      ADR.Latitude IS NOT NULL AND 
             ADR.Longitude IS NOT NULL AND 
             (3959 * acos(cos(radians(@Latitude)) * cos(radians(ADR.Latitude)) * cos(radians(ADR.Longitude) - radians(@Longitude)) + sin(radians(@Latitude)) * sin(radians(ADR.Latitude)))) &lt; @MilesRadius                       
  ORDER BY distance
  </code></pre>