Bug #16037 Why isn't (1.11 * 10) equal to 11.10?

Submitted: 28 Dec 2005 10:35 Modified: 28 Dec 2005 14:03
Reporter: Ola Oke Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.10a-nt OS:Windows (Windows 2000)
Assigned to: CPU Architecture:Any

[28 Dec 2005 10:35] Ola Oke
Description:
Is this due to a MYSQL bug?  Please read on:

I am using version: 4.1.10a-nt on Windows 2000

Can anyone please tell me why (1.11 * 10) is not equal to 11.10, in the query below. I expect the two to be equal because (1.11 * 10) is the same as 11.10, yet the query always brings back 0 which means false.

This is the query that does not bring back the expected result:
SELECT (1.11 * 10), (1.11 * 10) = 11.10
FROM dual

This query does bring back the expected result (Why is this correct whereas the first query - above - is not?):
SELECT (1.11 * 1), (1.11 * 1) = 1.11
FROM dual

Depending on your db vertion you may already have the dual table, therefore, please test these queries on your db for verification.

Note:  The answer to this puzzle will enable me to deal with a bug in our application.

Thank you.

Ola.

How to repeat:
To reproduce the 'bug', run this query:

This is the query that does not bring back the expected result:
SELECT (1.11 * 10), (1.11 * 10) = 11.10
FROM dual

(1.11 * 10) = 11.10 will bring back a value of 0 instead of 1
[28 Dec 2005 10:59] Valeriy Kravchuk
Thank you for a problem report. It is a well-known and documented feature (limitation) of all version up to 5.0.3. Please, read http://dev.mysql.com/doc/refman/5.0/en/precision-math-examples.html, for example.
[28 Dec 2005 14:03] Ola Oke
Noted.  Thanks.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.050 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.