0

I am sorry to bother people with silly questions, But I have no choice.

I have a statement

unsigned short a=4000, current_word;

current_word=a << 3;

Then I have another statement

unsigned long a=4000, current_word;

current_word=a << 19;

According to my knowledge they will contain the same value. Am I right?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by mbulow
0

When shifting the bits you loose the bits that gets "pushed out". You don't rotate the bits.

Lets look at your examples (in binary):

a: 0000111110100000
a << 3: 0111110100000000
a << 19: 0000000000000000
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.