C Programming - Bitwise Operators - Discussion

Discussion Forum : Bitwise Operators - True / False Questions (Q.No. 1)
1.
Left shifting a number by 1 is always equivalent to multiplying it by 2.
True
False
Answer: Option
Explanation:
0001 => 1
0010 => 2
0100 => 4
1000 => 8
Discussion:
9 comments Page 1 of 1.

Sathuragiri said:   1 decade ago
There will be no doubt if they directly given the qn as in binary representation of a number, left shifting it by one is e qual to multiplying it by 2. They hidden the term (Binary representation).

Rahul said:   8 years ago
What about 0 when it is left shifted ? Anybody give me the answer please.

I guess 0 left shifted by 1 becomes 1 which is not divisible by 2.
(1)

Charlie said:   1 decade ago
Not always. Bits fall off the end!

printf("%d\n", 1<<33);

Harshit Sharma said:   1 decade ago
It was not mentioned in the que that the no. was in binary representation?

Sathuragiri said:   1 decade ago
printf("%d\n",1<<33) what is this? it will print what?

David said:   8 years ago
The "answer" is wrong due to the possibility of overflow.
(1)

Vlknr said:   10 years ago
int a = 1 << 31;

a << 1! = a*2.

AdamK said:   9 years ago
Not always. Think about overflow cases.

Berci said:   1 decade ago
And what if you shift 1000?

Post your comments here:

Your comments will be displayed after verification.