ブックマーク / www.hyfr.life (1)

  • Bitwise operators and tricks! - hyfr!

    Returns 1 only if exactly one bit is set to 1 out of the two bits in comparison. Operates on two equal-length bit patterns, !(works on 1100 and 00) Binary operator. Left Shift ( << ): How it works Shift n number of bits to the left and append 0 at the end. Using this operator is equivalent to multiplying the bit pattern with 2 n ( if we are shifting n bits ) i.e. 1 << 1 (shift 1 bit so 21 = 2) = 2

    codehex
    codehex 2018/12/31
    よく見るビット演算のトリック集
  • 1