List:General Discussion« Previous MessageNext Message »
From:Hassan Schroeder Date:October 30 2005 1:04am
Subject:Re: float comparison?
View as plain text  
Scott Gifford wrote:

>>select * from price where amount = 3.45 // doesn't work

> Floating point numbers are very rarely equal, because of small
> rounding errors that happen all the time.  Probably the actual number
> in the database is something like '3.44000000000000001'.
> 
> Try something like this:
> 
>    select * from price where amount > 3.44 and amount <= 3.46

Or maybe             ... where ROUND(amount,2) = 3.45;

-- 
Hassan Schroeder ----------------------------- hassan@stripped
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                          dream.  code.


Thread
float comparison?Jerry Swanson29 Oct
  • Re: float comparison?Scott Gifford30 Oct
    • Re: float comparison?Hassan Schroeder30 Oct
      • Hi allFabricio Mota30 Oct
      • Re: float comparison?Michael Stassen31 Oct
        • Re: float comparison?Scott Gifford31 Oct
    • Re: float comparison?Joerg Bruehe31 Oct
RE: RES: Hi allSST - Adelaide)1 Nov
  • RES: RES: Hi allFabricio Mota1 Nov