List:General Discussion« Previous MessageNext Message »
From:Joerg Bruehe Date:October 31 2005 2:33pm
Subject:Re: float comparison?
View as plain text  
Hi!

Scott Gifford wrote:
> Jerry Swanson <pmysql@stripped> writes:
> 
> 
>>Why when I do select from database and try to compare float field with float
>>number, I have no results
>>
>>amount --- type float
>>
>>select * from price where amount = 3.45 // doesn't work
>>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.  [[...]]

This is the problem to convert fractions between the decimal and the 
binary system.

For a coarse analogy, try to express 1/3 exactly using a finite number 
of decimal digits.

For more info, AFAIK this is the standard reference:
http://cch.loria.fr/documentation/IEEE754/ACM/goldberg.pdf

Regards,
Jörg

-- 
Joerg Bruehe, Senior Production Engineer
MySQL AB, www.mysql.com
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