The integer variable num, for example, has a value of 22 and its binary version is 10110. Now we shift the binary bits 2 using the left shift operator, making num = num 2 equal to num = num * (22). And num now has a new value of 22* (2 2) = 88, which is the binary form 1011000.
Bit shifting is an operation that moves all of the bits in a binary value to the left or right by a certain number of places. When the operand is used as a series of bits rather than as a whole, bit shifting is performed.
The left shift operator (<<) shifts the first operand to the left by the provided number of bits. Extra bits that have been relocated to the left are discarded. From the right, zero bits are shifted in.
The binary left shift operator is used to multiply two integers by powers of two. This operator helps in aligning strings of text on the right side and for converting numbers from decimal to binary.
The left shift operator is a sort of Bitwise shift operator that uses binary bits to accomplish operations. It's a binary operator that requires two operands to shift or move the bits to the left side and add zeroes to the empty space formed on the right side after the bits have been shifted.
Share a personalized message with your friends.