, Exchange Rate, , , : 1.3462, :
$price = 89.99;
$quantity = 1;
$tax = 20;
$tax = $tax/100.0 + 1;
$exchangeRate = 1.5;
$totalPrice = $price*$quantity*$tax;
$totalPriceRounded = round($price*$quantity*$tax,2);
echo $totalPrice.'<br/>'.$totalPriceRounded;
:
107.988 // Test
107.99 // Test
, , , ? , , , GBP, . , , , , .
:
$totalPrice = round($totalPrice * $exchangeRate,2);
$totalPriceRounded = round($totalPriceRounded * $exchangeRate,2);
echo $totalPrice.'<br/>'.$totalPriceRounded;
:
// Amount in foreign currency
161.98 // Test
161.99 // Test
, , , 107.988 GBP, GBP .
$totalPrice /= $exchangeRate;
$totalPriceRounded /= $exchangeRate;
echo $totalPrice.'<br/>'.$totalPriceRounded;
:
// totalPrice in GBP currency
107.98666666667 // Test
107.99333333333 // Test
:
$totalPrice /= $tax;
$totalPriceRounded /= $tax;
echo $totalPrice.'<br/>'.$totalPriceRounded;
:
// the amount you get in GBP currency
89.988888888889 // End result of Test
89.994444444444 // End result of Test
, , in this case, round($price*$quantity*$tax*$exchangeRate, 2), , round(round($price*$quantity*$tax,2)*$exchangeRate, 2), , . , , , , .
, fixed prices, ( ), , ( ) . (.. round ) , . , , , / .
random prices, , , web servers, $0.01/second. / . , . , , . , , .
-, , :
$price = 4.47;
$quantity = 1.2
$totalPrice = round($price * $quantity, 2);
, , .
, :
$totalPrice = round($price*$quantity*$tax*$exchangeRate, 2);
, , , , . , , , , .
, // .. , , , .