Technical Discussion :: C
Home > Technical Interview Q&A > C > Discussion
24 / 123
What is equivalent of multiplying an unsigned int by 2: left shift of number by 1 or right shift of number by 1?
Answer:
multiplying a number by two is equivalent to bitwise left shift of a number by 1 for eg
1 has a binary representation as 00001 left shift by 1 will make it 00010 which is 2.
right shift is equivalent to divide a number by 2 .
left shift is equivalent to multiply a number by 2.
Asked In ::
multiplying a number by two is equivalent to bitwise left shift of a number by 1 for eg
1 has a binary representation as 00001 left shift by 1 will make it 00010 which is 2.
right shift is equivalent to divide a number by 2 .
left shift is equivalent to multiply a number by 2.