After a short Google session, I found that printf seems to be able to do the job, at least in bash (could not find the online interpreter that ksh does).
printf "%0.f\n" 4.51 5 printf "%0.f\n" 4.49 4
Code at: http://ideone.com/nEFYF
Note: perl may be redundant, as Marius says, but here is the perl path:
The perl Math :: Round module seems to be handling the job.
Single line:
perl -MMath::Round -we 'print round $ARGV[0]' 12.49
Script:
use v5.10; use Math::Round; my @list = (3.49, 2.9, 4.1, 23.51, 982.4999); say round $_ for @list;
Script output:
3 3 4 24 982
source share