Re: Math Weirdness

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

 



On Mon, Jul 14, 2008 at 3:54 PM, Daniel Brown <parasane@xxxxxxxxx> wrote:
>
>    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....
> ?>

    Sorry, I screwed up.  Because in that example, if $endingBal was
negative, it wouldn't work correctly.  Update it to this:

<?php
$totChargeDiff = ($totalCharges > $endingBal) && $endingBal >= 0 ?
($endingBal + $totalCharges) : ($endingBal - $totalCharges);
?>

-- 
</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.

-- 
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