assumed: value = 4.6
round = (value * 10) % 10;
round = (10 * (round >4) - round) / 10
# ^^^^^^^^____returns 1 if true
# (10-6)/10 = 0.4
# 4.6 + 0.4 = 5.0
value += round;
#gives: 5.0
---------------------------------------
assumed: value = 4.2
round = (value * 10) % 10;
round = (10 * (round >4) - round) / 10
# ^^^^^^^^____returns 1 if true
# (0-2)/10 = -0.2
# 4.2 + -0.2 = 4.0
value += round;
#gives: 4.0
---------------------------------------
i propose:
round = (value * 10) % 10;
round = 0 if(round == 5);
round = (10 * (round >4) - round) / 10 if(round != 0);
value += round;
will return:
4.0 if value was 4.4
4.5 if value was 4.5
5.0 if value was 4.6 -----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !