MySQL Forums
Forum List  »  PHP

Re: Decimal Compare not working
Posted by: Rick James
Date: June 18, 2014 03:21PM

Computation tends to be done in DOUBLE. Constants tend to be DOUBLE. Numbers stored in DECIMAL(..,..) are not DOUBLE. In many cases, MySQL "does the right thing". But in some cases, it will be converting between DECIMAL and DOUBLE (either direction) and introduce a rounding error.

Your examples show $M... variables -- this is not SQL syntax. Please show us the actual SQL that is causing trouble if you want us to dig deeper.

Another thing to note... When doing a SELECT, SQL will return a string, not a binary number. The language you are working in may then turn that string into a DOUBLE in the language, thereby (possibly) adding a rounding error _outside_ of MySQL.

Options: ReplyQuote


Subject
Written By
Posted
June 16, 2014 12:12PM
Re: Decimal Compare not working
June 18, 2014 03:21PM


Sorry, you can't reply to this topic. It has been closed.

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.