"LinuxGuy" <ra**********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hi,
I want to add bits to present number. Shift operator pushes bits and
add '0' at the end.
I want to shift bits and want to add 1 at end
Ex,
1)
suppose Input 0000
for 1 bit I want output as 0001
unsigned int x(0);
x |= 1;
2)
Input 0100
for 1 bit output should be
1001
unsigned int x(4);
x = (x << 1) | 1;
I'm not sure if the parentheses are strictly necessary,
I just used them to ensure order of operations rather
than having to look up precedence rules.
Finally, note that the number of bits used to represent
a given type depends upon the implementation, subject
to minimum requirements, e.g. 'unsigned int' must
have at least 16 bits, but could have more.
-Mike