I\'m wondering if I found an issue with the rounding in PHP, specifically 5.2.3 (I\'m not sure about other versions at the moment):
$t = 0;
$taxAmount = (5.
You can use PHP_ROUND_HALF_UP, but there's a issue that number self transform to "99999..."
Floats are evil.
Quoting the PHP manual documentation on Floating Point numbers:
So never trust floating number results to the last digit, and never compare floating point numbers for equality. If higher precision is necessary, the arbitrary precision math functions and gmp functions are available.
If you want to know why and how floats work I recommend watching:
Everything you didn't want to know about JavaScript numbers
Python says:
>>> repr(5./100*0.7)
'0.034999999999999996'
This is due to IEEE754 accuracy limitations. Use a fixed-point type if you need exact accuracy.