shaileshpatil

07-30-2008, 01:12 PM

Hi

I am doing simple addition and subtraction in php.

CASE 1

$lngAmountDifference = $lngInvoiceTotalAmountInclTax - $lngInvoiceTotalTaxAmount;

$lngAmountDifference = $lngAmountDifference - $lngSumOfItemAmount;

print 'DIFFERENCE ='.$lngAmountDifference.'<br>';

For some results its right and for some it prints 4.57775455E, even though the difference should be zero. Why this happens?

CASE 2

If i use (int)$var-(int)$var2, it is perfect, but as soon as bigger value appears, it ends up with same.

CASE 3

If i use (double)$var1-(double)$var2, still the results differ from all the cases mentioned above.

Plz help

Thanks in advance

I am doing simple addition and subtraction in php.

CASE 1

$lngAmountDifference = $lngInvoiceTotalAmountInclTax - $lngInvoiceTotalTaxAmount;

$lngAmountDifference = $lngAmountDifference - $lngSumOfItemAmount;

print 'DIFFERENCE ='.$lngAmountDifference.'<br>';

For some results its right and for some it prints 4.57775455E, even though the difference should be zero. Why this happens?

CASE 2

If i use (int)$var-(int)$var2, it is perfect, but as soon as bigger value appears, it ends up with same.

CASE 3

If i use (double)$var1-(double)$var2, still the results differ from all the cases mentioned above.

Plz help

Thanks in advance