Junior — Middle
How are signed integers represented in binary system?
sobes.tech AI
Answer from AI
Signed integers in binary are usually represented using two's complement. This allows for convenient arithmetic operations and unambiguous sign determination.
Key points:
- The most significant bit (MSB) indicates the sign: 0 — positive, 1 — negative.
- For negative numbers, all bits are inverted and 1 is added to the least significant bit.
For example, for an 8-bit number:
- +5 in binary: 00000101
- -5 in two's complement: invert 00000101 → 11111010, add 1 → 11111011
This representation simplifies addition and subtraction operations at the hardware level.