RE: Math Weirdness

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

 



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

Surely, for difference,
 $totChargeDiff = abs($endingBal - $totalCharges);

Alex

No virus found in this outgoing message. Scanned by AVG Free 8.0
Checked by AVG - http://www.avg.com 
Version: 8.0.138 / Virus Database: 270.4.10/1550 - Release Date: 13/07/2008
17:58


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