Live data from Hacker News

Do you know your bitwise operators?

quaxio.com

31–32 of 32 posts

Re: Do you know your bitwise operators?

#31
post #28

That will get fairly hairy, given that JavaScript doesn't have integers. x should be expected to be a IEEE 754 double (can one discriminate between NaNs in JavaScript?), but might also be a string (does "@" have one bit set?, or might it be EBCDIC?), an array, an object, null or undefined (do those have a bit pattern?)

JavaScript supports various bit manipulation operators, which treat their operands as 32 bits (and return a numerical value).

Re: Do you know your bitwise operators?

#32
post #28

That will get fairly hairy, given that JavaScript doesn't have integers. x should be expected to be a IEEE 754 double (can one discriminate between NaNs in JavaScript?), but might also be a string (does "@" have one bit set?, or might it be EBCDIC?), an array, an object, null or undefined (do those have a bit pattern?)

JavaScript supports various bit manipulation operators, which treat their operands as 32 bits (and return a numerical value).

Because of that, I am not sure can use them to count the number of 1 bits in a JavaScript number. For example, if x&0xFFFFFFFF equals 356621, what do you know of x?
Post reply on HN