Bug #21346 | Incorrect results are displayed when querying records what have float of >= x.29 | ||
---|---|---|---|
Submitted: | 30 Jul 2006 2:22 | Modified: | 30 Jul 2006 10:09 |
Reporter: | E Lau | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S1 (Critical) |
Version: | MySQL 5.0.18-nt | OS: | Windows (Windows XP) |
Assigned to: | CPU Architecture: | Any |
[30 Jul 2006 2:22]
E Lau
[30 Jul 2006 2:32]
E Lau
In 'Description' of bug, I meant "incorrect results", not "zero results".
[30 Jul 2006 10:09]
Hartmut Holzgraefe
That's how FLOAT works. FLOAT rule number one is "never compare floats for equality" as they are stored in binary internally, and for most decimal fractions threre is no exact representation in binary, just as there is no exact decimal representation of 1/3 (= 0.3333333...) for example. When dealing with monetary values like in your example DECIMAL is the type of choice, FLOAT is ment for more scientific values. It is a simple tradeof between precision and performance ...