Re: Math Weirdness

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux