Created
August 17, 2010 22:51
-
-
Save bmeck/532479 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function andOp(x,y) { | |
var xchunks=[],ychunks=[]; | |
while(x>0xffffffff){xchunks.push(x|0);x=(x/0x100000000)|0} | |
xchunks.push(x|0);x=(x/0x100000000)|0 | |
while(y>0xffffffff){ychunks.push(y|0);y=(y/0x100000000)|0} | |
ychunks.push( y|0); y=(y/0x100000000)|0 | |
//dont need to test lengths | |
var result = 0 | |
for(var i=ychunks.length-1;i>=0;i--) { | |
var chunk = ychunks[i] | |
result += (chunk & xchunks[i]) | 0 | |
console.log([chunk,xchunks[i],result]) | |
if(i>0) { | |
result *= 0x100000000 | |
} | |
} | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment