in reply to rounding to nearest
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"))'
|
|---|