[0004] Daily package array-slice

github Address: HTTPS: //github.com/ABCDdouyae ...

array-slice

Array taken, consistent with the array slice method
用法 : Array-slice (Array, Start, End)
返回 : Array
Source bit about the operation has been less focus on learning [bit computing, the next re-learning]
  • Bitwise NOT (~):对数字求负数并且减1
  • Bitwise AND (&):将两个数字的32位二进制对齐,每一位都求两者的AND运算
  • Bit operation XOR (|):将两个数字的32位二进制对齐,每一位都求两者的OR运算
  • Bitwise left shift operator (<<):将数字的32位二进制左移固定位数其他位置0替补
  • Bitwise signed right shift (>>):将数字的32位二进制右移固定位数其他位置0替补
  • No transport bit signed right shift (>>>):同有符号右移正数
let b = 10;//1010
let c = 5;//101
console.log(b&c);//0
console.log(b|c);//15
console.log(c<<3);//40
console.log(-c<<3);//-40
console.log(c>>3);//0
console.log(c>>1);//2
console.log(-c>>1);//-3
console.log(c>>>1);//2

/**
 *  b     0000 0000 0000 0000 0000 0000 0000 1010     10
 *  c     0000 0000 0000 0000 0000 0000 0000 0101      5
 *        =======================================
 * b&c    0000 0000 0000 0000 0000 0000 0000 0000      0
 * b|c    0000 0000 0000 0000 0000 0000 0000 1111     15
 * 
 * 
 *        0000 0000 0000 0000 0000 0000 0000 0101      5
 * c<<5   0000 0000 0000 0000 0000 0000 0010 1000     40
 * c>>3   0000 0000 0000 0000 0000 0000 0000 0000      0
 * c>>1   0000 0000 0000 0000 0000 0000 0000 0010      2
 * -c     1111 1111 1111 1111 1111 1111 1111 1011
 * -c>>1  1111 1111 1111 1111 1111 1111 1111 1101
 *       -0000 0000 0000 0000 0000 0000 0000 0011
 */   

Guess you like

Origin www.cnblogs.com/qianduanwriter/p/11814282.html