Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Perl: the Markov chain saw
 
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`


Comment on Re: Answer: How do I round a number?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://46952]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2014-04-19 13:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (480 votes), past polls