Can anyone tell me why the following code is:
var a = 0xFFFFFFFF ; A & amp; = 0xFFFFFFFF; A + = 1; Warning ("a =" + a); Var B = 0xFFFFFFFF; B + = 1; Alert ("B =" + B); Gives different values for A and B?
Since 0xFFFFFFF & amp; 0xFFFFFFFF should be equal to 0xFFFFFFFF, both pieces of code should return 0x100000000. Instead, get the value of 0x100000000 to the value of 0 and 0.
works with Javascript because signed integer, 4294967295 Can not be displayed in 32 bits, thus it becomes converted into a wider variety. var a = 0xFFFFFFFF; Warning ("a =" + a); // 4294967295 (too large for signed 32-bit integer) A & = 0xFFFFFFFF returns; // Signature integer alert on 32 bit as the result ("a =" + a); Details on Bitwise operators can be found here: If you can a to 0xFFFFFFF / code> (he 7 F ) you get the results you want. var a = 0xFFFFFFF; Warning ("a =" + a); // 268435455 returns & amp; = 0xFFFFFFFF; Warning ("a =" + a); Gives // 268435455
Comments
Post a Comment