Rounding up to the nearest 1
Posted: Wed Jul 02, 2003 1:55 pm
Hi,
I am working on a postal price calculator and it has all been well and good so far. However. when the weight exceeds 1000g, it costs 89p per 250g or part thereof after.
So far I have this, and this is good because it works out a fractioln of the excess charge and adds it. However, if the $excesschargeportions is anwhere between 0 and 0.999... for instance I need it to round to 1 so the whole 89p will be added.
Does anybody know how this can be done?
Many thanks,
Lawrence
I am working on a postal price calculator and it has all been well and good so far. However. when the weight exceeds 1000g, it costs 89p per 250g or part thereof after.
Code: Select all
<?php
if($postageweight>=1000 AND $deliverytype==rd){
$excessweight = $postageweight-1000;
$excesschargeportions = $excessweight/250;
$excesscharge = $excesschargeportions * 0.89;
$rawpostageprice = 4.31 + $excesscharge;
$postageprice = sprintf("%0.2f",$rawpostageprice);
}
?>Does anybody know how this can be done?
Many thanks,
Lawrence