On Friday 01 March 2002 2:51 pm, Thomas LaCicero wrote:
> I am not sure if this is going to sound like a stupid question but here it
> goes...
>
> If  I have a table with a  Float field and, an entry in that field that has
> at least one decimal place, and I try to do a SELECT * FROM some_table
> WHERE some_float_field = 3.2
>
> the query will return 0 rows even when there is a matching row.
>
> Hope I described this well .. I am running the latest 3.23 release (49a I
> think)
>
> Is this a bug in MySQL or does it have something to do with a SQL
> definition?

This is a bug in your understanding of floating point numbers.

The basic answer is that you cannot compare two floating point numbers in 
_ANY_ computer language using =.  Check a small delta around the number you 
are searching for or store the float field as an integer (e.g. 32 in the 
above).

This is related to the reason that you cannot write 1/3 in decimal... the 
number goes out to infinity.  Now, consider binary.

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to