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?

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.