[ database query mysql ]

Jim Dickenson wrote:

 > Am I to assume that based on your response that one should never use a float
 > field type if you ever want to select the data?


No, that wasn't quite what he said.

You can certainly select on a float field, as long as you perform a
meaningful operation.

For instance, if you want to check for "equality", then instead of "val =
10.1", you have to check for "abs(val-10.1) < 0.00001" (or whatever your
tolerance for inequality is).  Simple greater-than or less-than comparisons
are always, of course, OK.

Also, because of the equality problem, a "unique" index on a floating-point
quantity may not be unique: 12.299999 and 12.300001 may both get entered in
the database, and both display as "12.3".
--
Shankar.


---------------------------------------------------------------------
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