The perl documentation reads in part
...it probably pays not to trust whichever system rounding is being used by Perl, but to instead implement the rounding function you need yourself.
Here is a round function which behaves the way sane normal people would like.
sub round {
my( $num, $rnum );
$num = shift;
$rnum = $num - int($num);
if( $rnum >= .5 ) {
return int($num) + 1;
} else {
return int($num);
}
}
No comments:
Post a Comment