Here my brutal attempt translating in perl what i'd say in plain language. Note the
*10 at the begin and the
/10 at the end: they make your life easier confining the problem to one digit only.
use strict;
use warnings;
print map {
my ($int,$dec)=split /\./,$_*10;
$dec = defined $dec && $dec >= 5 ? 1 : 0;
sprintf("%.2f\n", ($int+$dec)/10);
} (<DATA>);
__DATA__
1.24
13.25
2.90
2.99
2.92
14
# OUT
1.20
13.30
2.90
3.00
2.90
14.00
HtH
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.