> -----Original Message-----
> From: Mike Craig [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 12, 2002 10:02 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Rounding a number 
> 
> 
> Hi,
>  
> Unless I have missed exactly what you need, this should work
> 
> take the int of Snum + 1

That works unless $num is already an integer.

I don't think he wants to round 1.0 to 2

ceil() avoids this problem.

> 
> Mike Craig
> 
> www.UltraTextPro.biz
> 
> 
> -----Original Message-----
> From: Bob Showalter [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 12, 2002 4:42 PM
> To: 'Octavian Rasnita'; [EMAIL PROTECTED]
> Subject: RE: Rounding a number
> 
> 
> > -----Original Message-----
> > From: Octavian Rasnita [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, September 12, 2002 4:54 AM
> > To: [EMAIL PROTECTED]
> > Subject: Rounding a number
> > 
> > 
> > Hi all,
> > 
> > I would like to round a number but to the next integer not 
> > like the int
> > function does.
> > 
> > I've tried:
> > 
> > my $num = 1.33;
> > $num = $num + 0.499999;
> > $num = sprintf "%.0f", $num;
> > 
> > This works but I am wondering if there is a cleaner and 
> > better solution
> > because there is a small chance not to work for some numbers.
> 
> It sounds like you want the POSIX ceil() function:
> 
> $ perl -MPOSIX -le 'print POSIX::ceil(1.33)'
> 2
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to