Home>

### basic information engineer - i don't know why 0b10000000 becomes -128 in an 8-bit environment with a sign

Please write the details of your question here.
I don't know why 0b10000000 becomes -128 in an 8-bit environment with a sign.

The problem i am having
``````−127 = 0b10000001
0b100000000 (128) --0b01111111 (127) = 0b10000001 (-127)
-1 is
0b100000000 (128) --0b00000001 (1) = 0b11111111 (-1)
I understand that.
That is, -127 to 127
It can be expressed by 0b10000001 to 0b11111111.
But I don't understand why 0b10000000 is -128.
0b100000000 (128)-0b100000000 (128) = 0b000000000 (-128 ??)
-128 ≠ 0b10000000 is not.

Instead of calculating by calculation like this
If -128 is expressed by 0b10000000, it will be possible to make effective use of bits (because the value that can be expressed by one increases).
In an 8-bit environment, when signed
Is it okay to recognize that I "decided" to express -128 as 0b10000000?``````
Supplementary information (FW/tool version, etc.)

Fundamental Information Technology Engineer Examination N-ary question

• Answer # 1

0b100000000 (128) --0b01111111 (127) = 0b10000001 (-127)
0b100000000 (128) --0b00000001 (1) = 0b11111111 (-1)

I don't know what the calculation is.
0b1_0000_0000 is 256 instead of 128, 128-127 is not -127 and 128-1 is not -1.

0b100000000 (128)-0b100000000 (128) = 0b000000000 (-128 ??)

Similarly, 0b1_0000_0000 is 256 instead of 128.
I don't know what you want to calculate, but if you set the first "128" to 0b1_0000_0000 (256) as above and the next "128" to 0b1000_0000, which is 128 correctly, wouldn't it be the result you want?

• Answer # 2

It ’s a simple two's complement representation.
If you subtract 1 from -127, it's -128.

What do you know about this?

• Answer # 3

All bits are written here. Can you understand if you look at the list?
List of 8-bit signed integers signed integer

• Answer # 4

Negative numbers can be thought of as follows.
For example, if you add a number X to 127 and it becomes 0, you can think of X as -127.
When representing a number with 8 bits (ignoring numbers over 8 bits). It will be as follows.

0b0111'1111 (127) + X = 0b0000'0000 (0) ⇒ X = 0b1000'0001 (-127)
Similarly,
0b0111'1110 (126) + X = 0b0000'0000 (0) ⇒ X = 0b1000'0010 (-126)
...
0b0000'0001 (1) + X = 0b0000'0000 (0) ⇒ X = 0b1111'1111 (-1)

For 128
0b1000'0000 (128) + X = 0b0000'0000 (0) ⇒ X = 0b1000'0000 (-128)

I'm adding the same thing, so it feels a little strange. I don't think the idea is wrong.