Hi,
this code doesn't work correctly:
<? $i = 0.00; $i += 5.99; $i += 20.00; $i -= 20.00; $i -= 5.99; echo $i."<br>"; ?>
output: 1.7763568394E-015
Any ideas ? Why does this happen ?
cu...
No idea why this happens, but it does work using the [man]bcmath[/man] functions
Thanks...
this helped.
But anybody got ideas why this happens ?!?
typecast error from string to float?
$i = 5.99;
Is $i already float ? or is it string until an oparator is used ?
It looks like an archaic rounding error to me
Looks like a floating-point rounding error to me as well (1/100 does not have a terminating binary expansion); generally it's more reliable to scale everything up into integers, work there, and then scale back afterwards.