"Brett W. McCoy" wrote:
> 
> On Wed, 8 Aug 2001, Fernando wrote:
> 
> > If there in perl any function that round a number for example:
> >
> > 13.96 to 14.00 or 14
> >
> > I don't want to use any module, just a simple function. Thanks for the help
> > I alwys receive.
> 
> perldoc -q round
> 
>        Does Perl have a round() function?
> 
>        Remember that int() merely truncates toward 0.

Try int(number+.5), it will round up anything more than
'.5' to the next integer --OR-- truncate less than '.5'
Learned that twenty years ago, in BASIC. :-)
Ken

>  For
>        rounding to a certain number of digits, sprintf() or
>        printf() is usually the easiest route.
> 
>            printf("%.3f", 3.1415926535);       # prints 3.142
> 
> -- Brett
>                                    http://www.chapelperilous.net/btfwk/
> ------------------------------------------------------------------------
> Except for 75% of the women, everyone in the whole world wants to have sex.
> - Ellyn Mustard
> 
> --
> 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