Re: Math Weirdness

From: Date: Mon, 14 Jul 2008 17:55:37 +0000
Subject: Re: Math Weirdness
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-276755@lists.php.net to get a copy of this message
On Mon, 2008-07-14 at 12:39 -0500, Jay Blanchard wrote: > /* calculate total balance with payments and adjustments */ > $totalBalance = $acct['BALANCE'] + $adjBalance; > echo number_format($totalBalance, 2, '.', '')."\t"; > > /* calculate total charges */ > $totalCharges = $intlLDCharges + $longDistance + $smsCharges + > $daCharges + $totalData + $roaming; > echo number_format($totalCharges, 2, '.', '')."\t"; > > /* > * calculate difference between total balance and total > charges > * if the amount matches the ending balance then all is OK > * if not calculate the difference > */ > $totBalDiff = $totalBalance - $totalCharges; > if($totBalDiff === $endingBal){ > echo "OK\t"; > } else { > /* what is the difference between the ending balance > and > the charges? */ > $totChargeDiff = $endingBal - $totalCharges; > echo number_format($totChargeDiff, 2, '.', > '')."\t"; > } What makes you think the problem is in this code? How about doing the following right before the block of code you've provided so that we can actually check the data with what you're using: <?php echo '$acct["BALANCE"]: '.$acct["BALANCE"]."\n"; echo '$adjBalance: '.$adjBalance."\n"; echo '$intlLDCharges: '.$intlLDCharges."\n"; echo '$longDistance: '.$longDistance."\n"; echo '$smsCharges: '.$smsCharges."\n"; echo '$roaming: '.$roaming."\n"; echo '$daCharges: '.$daCharges."\n"; echo '$totalData: '.$totalData."\n"; echo '$endingBal: '.$endingBal."\n"; ?> Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP

« previous php.general (#276755) next »