RE: [PHP] Math Weirdness

From: Date: Mon, 14 Jul 2008 19:29:55 +0000
Subject: RE: [PHP] Math Weirdness
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-276769@lists.php.net to get a copy of this message
[snip] Isn't it possible then that your data is out of synch between the current balance and the previous day's ending balance? [/snip] No, the values are there and correct (it is done with a snapshot). The correct numbers are being used in the math (as shown). When I do this....(as you suggested); if(abs($totBalDiff - $endingBal) < .000001){ echo "OK\t"; } else { /* what is the difference between the ending balance and the charges? */ $totChargeDiff = $endingBal - $totalCharges; echo number_format($totChargeDiff, 2, '.', '')."\t"; } You can see the abs value difference is extremely small and it causes things to work as expected. 0.1 should be equal to 0.1

« previous php.general (#276769) next »