What is -1 represented in bits?

What is -1 represented in bits? I forgot.
And what will be -1<<2 .It was in a lecture. I forgot where it was.

11111111111111111111111111111111

11111111111111111111111111111100
That is equal to -4

1 Like

11111111111111111111111111111100
That is equal to -4

How is this -4

It’s Binary signed 2’s complement Whereas when you will calculate it by multiplying with power 2 you will get an answer as
(11111111111111111111111111111100)₂ = (1 × 2³¹) + (1 × 2³⁰) + (1 × 2²⁹) + (1 × 2²⁸) + (1 × 2²⁷) + (1 × 2²⁶) + (1 × 2²⁵) + (1 × 2²⁴) + (1 × 2²³) + (1 × 2²²) + (1 × 2²¹) + (1 × 2²⁰) + (1 × 2¹⁹) + (1 × 2¹⁸) + (1 × 2¹⁷) + (1 × 2¹⁶) + (1 × 2¹⁵) + (1 × 2¹⁴) + (1 × 2¹³) + (1 × 2¹²) + (1 × 2¹¹) + (1 × 2¹⁰) + (1 × 2⁹) + (1 × 2⁸) + (1 × 2⁷) + (1 × 2⁶) + (1 × 2⁵) + (1 × 2⁴) + (1 × 2³) + (1 × 2²) + (0 × 2¹) + (0 × 2⁰) = (4294967292)₁₀
which is decimal number. Both are different.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.