# Why is ~0 a Sequence of 1s [closed]

Why is `~0` a sequence of `1` bits and not just a single bit? Where do the extra `1` bits come from? Does this mean `~1` a sequence of `0` bits or just a single `0` bit?

My understanding was that the `~` operator is applied on the specific bits mentioned.

-

## closed as unclear what you're asking by gnat, Kilian Foth, BЈовић, MichaelT, GlenH7Feb 27 '14 at 14:33

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

because `0` in the chosen representation (2's complement) is a sequence of `0`s, applying the bitwise NOT on it will naturally result in a sequence of `1`s

`1` is a sequence of `0`s followed by a single `1`

Remember that a computer will use all bits available to represent a number in a variable. In other words if you have a 64 bit variable then all 64 bits will be in use even if 90% of them are `0`.

-
Thanks. I wasn't thinking about 0 being the same as 00000...0. So does that mean ~1 (say 1 is 0000001) becomes 0 or 1111110? – clicky Feb 26 '14 at 11:33
@clicky 1111110. Those other bits don't disappear when you store 1, they are merely set to zero and hence affected by `~`. – delnan Feb 26 '14 at 11:42

Because that is what `~` does.

It flips the bits of the operand. If your language of choice treats that literal `0` as a byte value, it is essentially:

``````00000000
``````

When the bites are flipped using the `~` (bitwise NOT), the result is:

``````11111111
``````

In the same way that `~10` would turn:

``````00001010
``````

To:

``````11110101
``````
-
Ah. `0` is the same as `000000...0`, obvious but didn't think of that. Thanks. – clicky Feb 26 '14 at 11:29
@clicky - yeah, you need to think about how the computer represents the value internally. – Oded Feb 26 '14 at 11:30