Thank you @AkosLukacs for the speedy reply. Thanks for testing on different OS and browser. At least I can be assured I'm not going insane. ;-) (yet)
Always amazes me how each of us tackle problems. I'll take time to study the effort you put in. Still not solved though.
After I posted and gave it some thought, I wondered if a floating point issue might be at hand.
But if that be true, then Line L43 L44 in correct.js
var midsav = newDiv;
var lsbsav = newDiv;
would mean that the assignment of the same value is being corrupted. This would imply that the floating point value, of an identical value, is changing after the first assignment!!!
Nope no magic corruption:) Only different decimal precision
Look at code at line 57-L60:
/*57*/ var newDiv = 0xE4C000;
/*58*/ var msband = newDiv & 0xFFFF0000;
/*59*/ var midand = newDiv & 0x0000FF00;
/*60*/ var lsband = newDiv & 0x000000FF;
Going back from line 60-59-58:
Assign 3 variables using the value of a variable called newDiv and some binary operations. What's the value of newDiv at that moment in time? It's exactly 0xE4C000, because you just assigned that value at L57.
Anything happened before is irrelevant.
To demonstrate it (start with correct.js):
Add var bla = newDiv to L45
Add print('bla == 14991360:', bla == 14991360) to L66
var bla = newDiv
print('bla == 14991360:', bla == 14991360)
It will print bla == 14991360: false so, the bla variable still holds that almost-14991360-but-not-exactly value.
Just type bla-14991360 and you get -0. Or type (bla-14991360)*1e9, and you get the same -1.86264514923.
No corruption here, as far as I can tell, only different fraction handling.
bla == 14991360: false
© Espruino, powered by microcosm.
Report a problem