Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

RE: Answer: How do i round a generated number in Perl? ...math.round (as in javascript) ...?

by lhoward (Vicar)
on Jul 26, 2000 at 00:27 UTC ( #24344=note: print w/ replies, xml ) Need Help??


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

This concept presented above can be expanded to round to more (or less) percision than just "round number to nearest integer". i.e.

Round to nearest hundred (100):

$rounded=100*int(0.5+$number/100);
Round to nearst tenth (0.1):
$rounded=0.1*int(0.5+$number/0.1);
etc...
  • Comment on RE: Answer: How do i round a generated number in Perl? ...math.round (as in javascript) ...?
  • Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2016-06-25 05:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (323 votes). Check out past polls.