sprintf "%.0f", $nnot
sprintf "%d", $nThe latter "rounds towards zero" (AKA "truncate"), just like int does.
It seems strange to me that POSIX (a standard module) implements ceil() and floor() and zillions of (mathematical and other) functions, doesn't seem to include a round() function.
In reply to Re: rounding to nearest integer
by bart
in thread rounding to nearest integer
by dsm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |