Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Rounding up nearest ten, hundred etc

by Roy Johnson (Monsignor)
on Sep 27, 2004 at 16:41 UTC ( [id://394240]=note: print w/replies, xml ) Need Help??


in reply to Rounding up nearest ten, hundred etc

sub round_up { my $n = shift; my $scale = 10**int(log($n)/log(10)); $n = 9 if $scale == 1; #magic for single digits if ($n > $scale) { $n = int($n/$scale+1)*$scale; } $n; }

Caution: Contents may have been coded under pressure.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-19 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found