RPN calculator FIXED NO REALLY by nn

for(S=[i=0];l=readline(e=0);print(e||v.toFixed(v%1&&1)))for([,v]in l.split(' '))9-v?S[++i]=v:(v=v[1]?'%':v,u=S[i--],1/(v=v<'^'?eval(S[i]+v+u):Math.pow(S[i],u))?S[i]=v:e='ERR')

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page