Gossamer Forum
Home : General : Perl Programming :

Rounding :(

Quote Reply
Rounding :(
I think this has probably been asked before but I'm stuck and would appreciate any help. I am very new to CGI/Perl and I have written a small script and I have a variable which is used as follows :

for($i=($size)/2; $i<$size; $i++)
{
$outputType "<li> $bullets[$i] </li>\n";
}

At the minute I have "($size)/2" rounding down to 2 (if $size=5) but what I need to do is have it round up to 3, but still have the ability to manipulate it as an integer, not as a String. Can anyone suggest the best way of doing this ? $size varies between 0-10 depending on the entries in a form.

Thanks for any help,
Stuart.
me@stu.uk.com
Quote Reply
Re: [-=Stu=-] Rounding :( In reply to
use POSIX qw/ceil/;

print POSIX::ceil( 2.51 );

Last edited by:

Paul: May 7, 2002, 5:25 PM