MySQL Forums
Forum List  »  PHP

Decimal Compare not working
Posted by: Hans Brost
Date: June 16, 2014 12:12PM

I have 2 Decimal(8,5) fields in my DB (MACDPrev and MACD). When I look at a row in Search in PHP MyAdmin, they both show values of -0.00006.

However in my script a comparison of PHP is indicating one is less than the other.

The MACDDIR field is being set to 'U' instead of 'E':

If ($MstMACDPrev < $MstMACD)
$MstMACDDir = 'U';
else
If ($MstMACDPrev > $MstMACD)
$MstMACDDir = 'D';
else
$MstMACDDir = 'E';

Other comparisons also show them as one being larger than the other instead of being equal

I thought Decimals were stored as exact values with the indicated nr of decimal places?


z

Options: ReplyQuote


Subject
Written By
Posted
Decimal Compare not working
June 16, 2014 12:12PM


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.