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:
© Espruino, powered by microcosm.
Report a problem