# Thread: Question about Bit Manipulation.

1. ## Question about Bit Manipulation.

Hi,I'm new to This Forum and New to C as well.
I have this Question in my Mind,can someone please Answer It.

Can someone please Explain this Bit manipulation Table.

Consider multiplication of a number by 2,do this by shift in memory Location.

Value of m____Bit Representation of m__Bits after Bit Shift________Value in m after bit shift
1_____________0000 0001____________0000 0010_________________2
2 ____________0000 0010____________0000 0100_________________4
3____________ 0000 0011____________0000 0110_________________6

Please guys I need a Logical Explanation for this.
I Know its simple,but just can get around It.

2. Presumably you know which way left is. What exactly is your question?

3. Yes,I know The Table didn't come out properly,but I tried my best to make It appear properly.
Basically I wanted an Explanation of Bit manipulation in C.

The Question is
Q.Shift Bits of memory location m to the left by one position.

That Table is the answer,but I wanted to know How?

4. Perhaps it would help to think in terms of place-value notation.
Code:
```123 = 1 * 10^2 + 2 * 10^1 + 3 * 10^0

similarly in binary
0010 = 0 * 2^3 + 0 * 2^2 + 1 * 2^1 + 0 * 2^0 == decimal 2
0100 = 0 * 2^3 + 1 * 2^2 + 0 * 2^1 + 0 * 2^0 == decimal 4```

5. In our normal number system (base 10), every time you move a digit one column to the left, you multiply it's value * the base (which is 10).

00000001 = 1
00000010 = 1 * 10

In the binary number system (base 2), every time you move a digit one column to the left,
you multiply it's value * the base (which is 2).

00000001 = 1
00000010 = 1 * 2

In hexadecimal (base 16), every time you move a digit one column to the left,
you multiply it's value * the base (which is 16).

00000001 = 1
00000010 = 1 * 16

You see the pattern, no doubt. It's just arithmetic with different number bases.

6. Thanks for the Answers guys,I'll Try and Brush through and lend a little bit of Brain into the Answers.!

Popular pages Recent additions