# 1.1 => 1; 1.9 => 1; -1.1 => -2; -1.9 => -2 $rounded = POSIX::floor($value); # 1.1 => 2; 1.9 => 2; -1.1 => -1; -1.9 => -1 $rounded = POSIX::ceil($value); # 1.1 => 1; 1.9 => 2; -1.1 => -1; -1.9 => -2 $rounded = round($value); sub round { $_[0] > 0 ? int($_[0] + .5) : -int(-$_[0] + .5) }
In reply to Re: How do I round a number?
by japhy
in thread How do I round a number?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |