use POSIX qw( ceil ); my $rounded = ($num>=0 ? +1 : -1) * ceil(abs($num)*2)/2;