Re: Math Weirdness

From: Date: Mon, 14 Jul 2008 19:54:56 +0000
Subject: Re: Math Weirdness
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-276779@lists.php.net to get a copy of this message
On Mon, Jul 14, 2008 at 3:51 PM, Daniel Brown <parasane@gmail.com> wrote: > > You're performing math to get the result for $totChargeDiff by > subtracting $totalCharges from $endingBal. That will give you -0.10 > in this case, because 0.10 - 0.20 = -0.10. You want the difference, > not the result. Oh, and the code, by the way: <?php // .... your code to this point.... /* what is the difference between the ending balance and the charges? */ $totChargeDiff = ($totalCharges > $endingBal) ? ($endingBal + $totalCharges) : ($endingBal - $totalCharges); echo number_format($totChargeDiff, 2, '.', '')."\t"; // .... and continue with your code here.... ?> -- </Daniel P. Brown> Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo.

« previous php.general (#276779) next »