Web design course - B Bit-field (Definition) Op Description | Bitwise

B Bit-field (Definition) Op Description | Bitwise inclusive OR ^ Bitwise XOR (exclusive OR) &= Bitwise AND and assign to an LValue |= Bitwise inclusive OR and assign to an LValue ^= Bitwise exclusive XOR and assign to an LValue <<= Bitwise shift left and assign to an LValue >>= Bitwise shift right and assign to an LValue >>>= Bitwise shift right (unsigned) and assign to an LValue The bits are individually weighted according to their position relative to the least significant digit. The single bit at the extreme right-hand end is defined by the integer value 1. The next significant bit is derived by using a zero-based indexing scheme to raise 2 to the power of its index position. Thus 2 raised to the power 0 is 1. The value 2 raised to the power 1 is 2 and thus the values proceed like this, moving from right to left: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 etc. To build bit masks containing a set bit for several positions, simply add the component bit values together. Thus a mask that includes all the four least significant bits in a value is equal to: 1 +2 +4 + 8 Here are some other useful mask values (note that we only show 8 bit values here to demonstrate the concept): 0000 0001 0000 1111 0010 0000 0101 0101 0111 1111 1111 0000 1111 1111 Mask Value Description 1 15 32 85 127 240 255 Least significant bit Least significant nibble ASCII upper/lowercase character bit Simple encryption pattern for XOR Valid ASCII character mask Most significant nibble Low 255 UNICODE character set mask See also: Bit,Bitwise AND (&), Bitwise AND then assign (&=), Bitwise expression,Bitwise NOT complement (~), Bitwise operator,Bitwise OR (|), Bitwise OR then assign (|=), Bitwise shift left (<<), Bitwise shift left then assign (<<=), Bitwise shift operator,Bitwise shift right (>>), Bitwise shift right and assign (>>=), Bitwise unsigned shift right (>>>), Bitwise unsigned shift right and assign (>>>=), Bitwise XOR (^), Bitwise XOR and assign (^=),Expression

Leave a Reply