Fair points. I use bitwise operators in two cases currently:

- For constructing Morton numbers (mapping two dimensions to one). From Wikipedia: "[...] a Morton number is a single integer value constructed by interleaving the bits or digits of one or more source numbers."

http://en.wikipedia.org/wiki/Morton_number_(number_theory)

- For addressing Virtual Earth tiles (which uses a quadtree). From MSDN: "To convert tile coordinates into a quadkey, the bits of the Y and X coordinates are interleaved, and the result is interpreted as a base-4 number [...]"

http://msdn.microsoft.com/en-us/library/bb259689.aspx
In both cases, the functions are only called with integer numbers. You're right that in Javascript, all numbers are technically doubles, but yet using the bitwise operators seems to work perfectly well. I'm not sure.

I'm also not sure about whether that indeed optimizes anything. I haven't done profiling comparisons; I'm just reusing well-known algorithms.

--- In jslint_com@yahoogroups.com, "christian.wirkus" <christian.wirkus@...> wrote:

>

> Off the topic:

> Are you sure bitwise operators optimize anything in Javascript?

> Javascript isn't C, and the data type number is 64 bit float, not integer.

>