How embarrassing...I looked at the Match functions but can't get this simple stuff to work.
$unitprice = "10.00";
$tax = "0.825";
$shipping = "5.00";
$total = $unitprice * $tax;
$total = $total + $shipping;
The actual tax is 0.825 ... I need to round up to .xx ... so, .825 would be .83 whereas .824999 would be .82 and...
...the answer &should* be: 10.00 + .83 + 5.00 = $15.83 but I get $5.285 which is, of course, wrong.
Thanks to anyone who can help...including the rounding up/down based upon the .xxY "Y" position to only 2 decimal places.
(EDIT🙂 Oh "Duh!" (on me) ... I must add the calculated $tax TO the $total. There must be some elegant way of doing all this?
This:
$total = $unitprice * (1 . $x_tax);
... gives me $15.825 but still need to get to $15.83 (or $15.82 if the tax is 0.82000 through 0.824999.
(EDIT#2):
OK...I get this to work in the HTML section:
Total Amount : <?=printf('%.2f', $total;?> <BR />
It just seems a bit 'messy' ???