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

Answer: How do I round a number?

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

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

How about
Use integer; $thevalue*=1;
Seems the simplest, IMHO. It rounds everything down, btw - so it acts kinda like 'div' in PASCAL. That's where it's useful. For rounding to the nearest, use any of the above.

Comment on Answer: How do I round a number?
Download Code
RE: Answer: How do I round a number?
by Anonymous Monk on Sep 11, 2000 at 04:11 UTC
    I think you mean int?(been a while since I used pascal). Div was the divisor operation. The result being not a rounded down number, but the divisor of the operation. as in: 5 div 2 = 2 meaining 5/2 = 2 remainder 1 . Div returns the 2, Mod returns the 1. Admittedly this is irrelivant to the origonal question, but... :)
Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (15)
As of 2015-07-02 13:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (40 votes), past polls