Numbers can be integers or floating point numbers. Negative numbers are represented using sign and magnitude or two's complement. In CPUs, binary numbers need to be added together.

Another method of representing signed numbers is **two's complement**. Most computers use this method to represent negative numbers. This method can be more effective when performing mathematical operations like adding and subtracting.

With two's complement, the bit at the far left of the bit pattern - the **most significant bit** or **MSB** - is used to indicate positive or negative and the remaining bits are used to store the actual size of the number. Positive numbers always start with a 0.

Four-bit, positive, two's complement numbers would be 0000 = 0, 0001 = 1, up to 0111 = 7. The smallest positive number is the smallest binary value.

Negative numbers always start with a 1. The smallest negative number is the largest binary value. 1111 is -1, 1110 is -2, 1101 is -3, etc down to 1000 which represents -8.

- Find the positive binary value for the negative number you want to represent.
- Add a 0 to the front of the number, to indicate that it is positive.
- Invert or find the complement of each bit in the number.
- Add 1 to this number.

**Find -1 using two's complement numbers**

- 1 = 001
- Adding 0 to the front becomes
**0001** - 'Inverted' becomes
**1110** - Add 1 =
**1111**(**-8 + 4 + 2 + 1 = -1**)

**Find -4 using two's complement numbers**

- 4 = 100
- Adding 0 to the front becomes
**0100** - 'Inverted' becomes
**1011** - Add 1 =
**1100**(**-8 + 4 = -4**)

This table shows the two's complement set for 4-bit numbers.

Denary | 4-bit binary |
---|---|

-8 | 1000 |

-7 | 1001 |

-6 | 1010 |

-5 | 1011 |

-4 | 1100 |

-3 | 1101 |

-2 | 1110 |

-1 | 1111 |

0 | 0000 |

1 | 0001 |

2 | 0010 |

3 | 0011 |

4 | 0100 |

5 | 0101 |

6 | 0110 |

7 | 0111 |