java bitwise left shift

This question already has an answer here:

  • What are bitwise shift (bit-shift) operators and how do they work? 8 answers

  • left shift by one bit moves all the bits in the value one bit position to the left. The position that gets free at the right side is filled with bit 0, the bit that was farmost left is lost.

    This is the same effect as multiplying the value by 2.

    Example (using just 8 bits for simplicity):

    original value     10010011
    after shift left   00100110
    

    If you shift left by n bits, just repeat that n times (provided n is smaller than the word length). For n larger than the word length shift by n % wordLength.

    链接地址: http://www.djcxy.com/p/12590.html

    上一篇: MSVC等同于

    下一篇: java按位左移