Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Best way to round a number.

by Perlbotics (Chancellor)
on Oct 26, 2012 at 21:07 UTC ( #1001137=note: print w/replies, xml ) Need Help??


in reply to Best way to round a number.

use strict; use warnings; sub round5 { my $num = shift; return $num+2 - ($num+2) % 5; # <------ TIMTOWTDI ;-) } for (0..10) { printf "%3d -> %3d %3d -> %3d\n", $_, round5($_), -$_, round5(-$_); } __DATA__ 0 -> 0 0 -> 0 1 -> 0 -1 -> 0 2 -> 0 -2 -> 0 3 -> 5 -3 -> -5 4 -> 5 -4 -> -5 5 -> 5 -5 -> -5 6 -> 5 -6 -> -5 7 -> 5 -7 -> -5 8 -> 10 -8 -> -10 9 -> 10 -9 -> -10 10 -> 10 -10 -> -10

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001137]
help
Chatterbox?
LanX ... on monster.com
[r@j]: # list all of a user's processes my $process_java = $lConfig_Hash{$MFT _CMD."_java"}; my $Process = find_proc(user=>' raj', detail=>1) || die "Sorry, $Process_java is not running" ; if(proc_exists( name=>'$Process_ja va')){
[LanX]: see SOPW
[r@j]: guys i am begginer on perl and above code is not working on window environment.kindly suggest which support on both window and Unix environment

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (14)
As of 2017-10-23 15:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (280 votes). Check out past polls.

    Notices?