I am totally buffaloed by a set of very simple calculations that I am
doing;

/* 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";
        }

Each number represented by a variable in all of these calculations has
been rounded to 2 decimal points at the point they are generated. For
the most part this works just hunky-dory but I have a handful of calcs
(out of 300k plus records) that look like this....

$endingBal              0.10
$totalBalance   0.30    
$totalCharges   0.20
$totalChargeDiff        -0.10

The balance minus the charges does equal the ending balance as it should
but it is saying that it doesn't and that there a 20 cent swing (-0.10
is 20 cents different than 0.10).

I must be missing something. When I echo out raw data I do not see
negative signs. Does anyone have any insight as to what might be
happening here? 

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

Reply via email to