As @Doug Currie put it you need to represent the 64-bit number as two numbers, then do bit-wise operations on them. The code I ve used is:
//Constructor for a Long..
function Long(high, low) {
//note: doing "or 0", truncates to 32 bit signed
//big-endian 2 s complement int..
this._high = high | 0;
this._low = low | 0;
}
Long.prototype.rotateLeft = function(bits) {
var newHigh;
if(bits === 32){ //just switch high and low over in this case..
newHigh = this._low;
this._low = this._high;
this._high = newHigh;
} else {
newHigh = (this._high << bits) | (this._low >>> (32-bits));
this._low = (this._low << bits) | (this._high >>> (32-bits));
this._high = newHigh;
}
return this; //for chaining..
};
//Rotates the bits of this word round to the right (max 32)..
Long.prototype.rotateRight = function(bits) {
var newHigh;
if(bits === 32){ //just switch high and low over in this case..
newHigh = this._low;
this._low = this._high;
this._high = newHigh;
} else {
newHigh = (this._low << (32-bits)) | (this._high >>> bits);
this._low = (this._high << (32-bits)) | (this._low >>> bits);
this._high = newHigh;
}
return this; //for chaining..
};
To use it try running: console.log(new Long(0,1).rotateLeft(4));
then inspecting the _high and _low properties.