I understand the issues about binary precision for floating point numbers on 
standard base 2 systems but I'm unsure of the propper way to fix this 
problem.  Here is the base test case:

$contract_amount = 9961.00;
$bill1 = .95;
$bill2 = .05;

$billable_this_month += ($contract_amount * $bill1);

$paid_to_date += ($contract_amount * $bill2);

echo    "conditional: if(($paid_to_date + $billable_this_month) >= 
if(($paid_to_date + $billable_this_month) >= $contract_amount) {
        echo    "true";
else {
        echo    "false";

This is mostly a cut and paste of a problem that I am trying to fix for a 
client for a particular record which is coming out of the database and not 
evaluating like I want it to.

you would expect (498.05 + 9462.95) to be equal to 9961.00 .  In the case of 
this problem, all variables in question are of type double at time of 

ideas?  I tried casting to various different types without success.  I'd 
prefer not to round if at all possible...


Marc Swanson
MSwanson Consulting

Phone:  (603)868-1721
Fax:    (603)868-1730
Mobile: (603)512-1267


PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to