35 lines
615 B
HTML
35 lines
615 B
HTML
<script>
|
|
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators
|
|
|
|
// http://www.ti.com/lit/ds/symlink/opt3001.pdf
|
|
var x = 15390;
|
|
var v = 15 << 10;
|
|
|
|
var r = x & v;
|
|
var o = x & ~v;
|
|
|
|
console.log('x',x.toString(2));
|
|
|
|
console.log('r',r.toString(2));
|
|
console.log('o',o.toString(2));
|
|
var m;
|
|
for (var t=0;t<16;t++)
|
|
{
|
|
m = v >>> t;
|
|
|
|
console.log(m.toString(2), t);
|
|
console.log(x.toString(2));
|
|
}
|
|
|
|
for (var t=0;t<16;t++)
|
|
{
|
|
m = v << t;
|
|
console.log(m.toString(2), t);
|
|
console.log(x.toString(2));
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
a[0] | (a[1] << 8)
|