Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Answer: How do I round a number?

by I0 (Priest)
on Dec 16, 2000 at 02:38 UTC ( #46952=note: print w/replies, xml ) Need Help??


in reply to Answer: How do I round a number?
in thread math

$rounded = int ( $orig + 0.5 ) assumes $rounded is positive.
More generally:  use POSIX; $rounded = floor ( $orig + 0.5 )
or $rounded = sprintf( "%.f" , $orig ) to properly handle the half-way case
See also `perldoc -q round`

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://46952]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2016-12-03 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (56 votes). Check out past polls.