The impractical, but effective way of solving that is to turn every expression of the form x op y (where op is an operator such as +, -, *, /, etc. but not operators such as &, |, ^, << and >>) into (x op y) | 0. Otherwise, the engine will generally use floating point math and arbitrarily limit the output string to [-]999999 (otherwise converting to scientific notation). For example, instead of x * y + z you can try (((x * y) | 0) + z) | 0 (you can probably omit some of those parens, I don't remember at the moment).