sub round { my ( $price, $round ) = @_; return int(( $price / $round ) + 0.5 ) * $round; } print round( 418, 10 ), "\n";
The round subroutine takes two parameters, the number to be rounded and the nearest value to which you want it to be rounded to.
perl -le 'print+unpack("N",pack("B32","00000000000000000000001001000001"))'
In reply to Re: rounding to nearest
by rob_au
in thread rounding to nearest
by Cockneyphil
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |