That's a good suggestion, but beware that sprintf uses the round-to-even method of rounding.
$ perl -e 'printf "%.0f\n", 2.5;' 2 $ perl -e 'printf "%.0f\n", 1.5;' 2
To get the usual "round up" method, I usually use int with the value plus a half.
$ perl -le '$x=1.5;print int($x+.5)'; 2 $ perl -le '$x=2.5;print int($x+.5)'; 3
In reply to Re^2: int's behaviour
by kyle
in thread int's behaviour
by last_stand
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |