This commit is contained in:
Martin Donnelly 2016-05-20 17:17:29 +01:00
parent 939a7aff4c
commit 73decdcdb2

View File

@ -1,19 +1,31 @@
<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 v = 15390;
console.log(v.toString(2));
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;
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));
console.log(m.toString(2), t);
console.log(x.toString(2));
}