Rounding the figures:
$line = 630;
$line = $line - ($line % 65);
$lines = $line/65;
The above given simply divides 630 by 65 and give the result for 9.692 in rounded figures i.e. 9 only.
---------
I also used the sprintf function to get the result in rounded figures like...
$line = 630;
$line = $line - ($line % 65);
$lines = $line/65;
$rounded = sprintf("%.2f", $lines);
print "$rounded\n";
-------------
Both of these are working fine, but as you see if the result is greater than 9.5, it should be rounded to 10 and if its less than 9.5 (as per rules of mathematics) it should be rounded to 9 and this piece of code even round 9.99 to 9? Is there any way to round the figures e.g. to 10 when its greater than 9.5
Any help?
TIA,
Zeshan.
$line = 630;
$line = $line - ($line % 65);
$lines = $line/65;
The above given simply divides 630 by 65 and give the result for 9.692 in rounded figures i.e. 9 only.
---------
I also used the sprintf function to get the result in rounded figures like...
$line = 630;
$line = $line - ($line % 65);
$lines = $line/65;
$rounded = sprintf("%.2f", $lines);
print "$rounded\n";
-------------
Both of these are working fine, but as you see if the result is greater than 9.5, it should be rounded to 10 and if its less than 9.5 (as per rules of mathematics) it should be rounded to 9 and this piece of code even round 9.99 to 9? Is there any way to round the figures e.g. to 10 when its greater than 9.5
Any help?
TIA,
Zeshan.