[EMAIL PROTECTED] schreef:

> How do I round off a decimal to the next nearest whole digit ,
> example
> 0.123 = 1,
> 1.23 = 2,
> 4.7312 = 5, etc etc.....

Define "next".

You can use POSIX::ceil(),
but then -1.23 becomes -1 and you might want -2 there?

$ echo -1.23 4.1 5 |perl -MPOSIX -nwle'print ceil($_) for split'
-1
5
5

$ echo -1.23 4.1 5 |perl -MPOSIX -anwle'print $_<0 ? floor($_) :
ceil($_) for @F'
-2
5
5

-- 
Affijn, Ruud

"Gewoon is een tijger."


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to