I am trying to solve this problem:
When I purchase items I receive a receipt which lists the name of all the items and their price (including tax), finishing with the total cost of the items, and the total amounts of sales taxes paid. The rounding rules for sales tax are that for a tax rate of n%, a shelf price of p contains (np/100 rounded up to the nearest 0.05) amount of sales tax.
So, ... I have a price in php:
$value = 11.25;
and I don't understand why
var_export(ceil($value * 0.05 * 10));
returns 6 and dividing per 10, the result is
var_export(ceil($value * 0.05 * 10) / 10);
0.59999999999999998
some nice experiments:
php > echo bcmul(11.25, 0.05, 3);
0.562
php > echo bcmul(ceil(11.25), 0.05, 3);
0.60