Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Answer: How do I round a number?

( #24341=categorized answer: print w/ replies, xml ) Need Help??

Q&A > math > How do I round a number? contributed by jlistf

POSIX probably has an appropriate routine that'll do just that. You could also try using sprintf with the appropriate %0.2f (or whatever precision you're looking for). finally (TMTOWTDI), you could use the int keyword to truncate it, which might be more effective. for example, to generate dice rolls:
int( rand 6 ) +1;

Comment on Answer: How do I round a number?
Download Code
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2015-12-01 21:12 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (27 votes), past polls