The point is -IMO - there is something wrong with floating point calculation. The bit-mask mismatch is a result of the floating point error.

The result of calculation 915E6 * Math.pow(2,19) in Espruino is not 479723520000000, it's 479723519999999.9375.

915E6 * Math.pow(2,19)

To demonstrate it, ran this in

Results are identical in non-Espruino environments:

> 915E6 * Math.pow(2,19) // The result in Espruino: 479723519999999.9375 // The result in browser / node / F#: 479723520000000

Oh, btw just bit-shifting indeed wraps around in browser & node:

> 915E6<<10 657129472 > 915E6<<11 1314258944 > 915E6<<12 -1666449408 > 915E6<<13 962068480 > 915E6<<14 1924136960 > 915E6<<15 -446693376 > 915E6<<16 -893386752 > 915E6<<17 -1786773504 > 915E6<<18 721420288 > 915E6<<19 1442840576

@AkosLukacs started

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.

AkosLukacsThe point is -IMO - there is something wrong with floating point calculation. The bit-mask mismatch is a result of the floating point error.

The result of calculation

`915E6 * Math.pow(2,19)`

in Espruino is not 479723520000000, it's 479723519999999.9375.To demonstrate it, ran this in

Results are identical in non-Espruino environments:

Oh, btw just bit-shifting indeed wraps around in browser & node: