Offtopic: 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.
Ontopic (Espruino 2v04.6)
and one fix is to manually round the pow result:
>524288 === Math.pow(2,19)
>524288 === Math.round(Math.pow(2,19))
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, powered by microcosm.
Report a problem