Another fix is to use 524288 instead of Math.pow(2,19) for this calculation.
And of course that result should be rounded before it is used for binary operations.

Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.

maze1980Offtopic: Try 0.1+0.2 in nodejs(v10.15.1) and in Espruino (2v04.6).

Results are 0.30000000000000004 for nodejs and 0.3 for Espruino.

That's Javascript, and you should always keep in mind how numbers are represented internally.

Ontopic (Espruino 2v04.6)

and one fix is to manually round the pow result:

Another fix is to use 524288 instead of Math.pow(2,19) for this calculation.

And of course that result should be rounded before it is used for binary operations.