Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Round up 3 values to the next 100

by imp (Priest)
on Feb 14, 2007 at 06:39 UTC ( #599864=note: print w/replies, xml ) Need Help??

in reply to Round up 3 values to the next 100

What's wrong with traditional rounding?
my $c = 786733; my $rounded = 100 * int(($c+ 50) / 100);
If you are looking to always skip to the next 100 then change the 50 to 100. If you want to round up except if it is already divisible by 100, then add 99. For example:
my $c = 786001; print 100 * int(($c + 99) / 100);

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://599864]
[hippo]: erix++: "the browser ate my code"
[robby_dobby]: Eily: Now, people are trying to be inventive with crowdsourcing their work, eh? Sure, call on the admins to k-line these sockpuppet accounts!
[robby_dobby]: hippo: I like how you equated your browser to a dog....
[Eily]: well, Anonymonk is everyone's sockpuppet :D

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-04-25 13:16 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (454 votes). Check out past polls.