I didn't understand what you were saying at first, but I totally get what you mean
if you open the debugger you see the script is interpreted as
PHP Code:
if (keydown(0)) {
val = val+(0.5);
}
else if (keydown(2)) {
val = val-(0.5);
}
seems very wrong....
online, clientside, my results were even stranger
from 0 to 1, it only added in 0.05 increments, but after 1 it added in 0.005 increments