I have a problem that I can't seem to solve. I have checked the round,
ceil and floor functions and they don't seem to do what I want.
I have an entry like this
<?php
$tax = .065;
$ad2day = 104.50;
$ad2day = round(($ad2day * $tax)+ $ad2day, 2);
echo printf ("%.2f", $ad2day);
?>
That outputs $111.29, the result of multiplying 104.50x.065 with the
answer rounded to 2 decimal places, then adding in the 104.50 of the
$ad1day variable.
What I want to do is multiply the $ad2day variable by the $tax and come
up with a result that will round up any remainder past two decimal
places to the next decmial place. In the example above, the ($ad2day *
$tax) comes out to 6.7925. I want to round that up to 2 decimal places
to 6.80 if there is *any* remainder past the two digits. So 6.2401 would
be 6.25, 6.2499 would be 6.25, etc.
Round doesn't seem to do it and ceil only works (i think anyway)
rounding up to whole numbers. What do I need to do to get the result the
way I want it?
Thanks
ceil and floor functions and they don't seem to do what I want.
I have an entry like this
<?php
$tax = .065;
$ad2day = 104.50;
$ad2day = round(($ad2day * $tax)+ $ad2day, 2);
echo printf ("%.2f", $ad2day);
?>
That outputs $111.29, the result of multiplying 104.50x.065 with the
answer rounded to 2 decimal places, then adding in the 104.50 of the
$ad1day variable.
What I want to do is multiply the $ad2day variable by the $tax and come
up with a result that will round up any remainder past two decimal
places to the next decmial place. In the example above, the ($ad2day *
$tax) comes out to 6.7925. I want to round that up to 2 decimal places
to 6.80 if there is *any* remainder past the two digits. So 6.2401 would
be 6.25, 6.2499 would be 6.25, etc.
Round doesn't seem to do it and ceil only works (i think anyway)
rounding up to whole numbers. What do I need to do to get the result the
way I want it?
Thanks
Comment