in reply to rounding to nearest integer
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: rounding to nearest integer
by Anonymous Monk on Feb 03, 2020 at 01:42 UTC |