ELI5: Explain Like I'm 5

Signed number representations

Signed number representations are a way to show both positive and negative numbers on a number line. Imagine you have a number line in front of you with zero in the middle. Going to the right of zero are all the positive numbers and to the left are all the negative numbers. Now, if someone asks you to show the number 2, you'd go to the right on the number line until you reach the second spot from zero. But what do you do if someone asks you to show -2? This is where signed number representations come in.

One way to show negative numbers is to put a minus sign (-) in front of the number, like -2. Another way is to use parentheses, like (-2). Both of these methods show that the number is less than zero.

But when we need to do calculations with positive and negative numbers, it can get confusing. To help us out, there are different types of signed number representations that make it easier to add, subtract, multiply, and divide positive and negative numbers.

One such representation is called the "signed magnitude" representation. In this method, the leftmost digit represents whether the number is positive or negative. If the leftmost digit is a 1, the number is negative. If it is a 0, the number is positive. The other digits show the magnitude or size of the number. So, for example, the number +5 would be represented as 00000101 and the number -5 would be represented as 10000101.

Another type of signed number representation is called "two's complement." In this method, negative numbers are represented by flipping all the bits in the binary representation of the positive number and adding 1. For example, to represent -5 using two's complement, we would start with the binary representation of +5, which is 00000101, flip all the bits to get 11111010, and then add 1 to get 11111011.

In both of these methods, it's important to keep track of the leftmost bit to know whether the number is positive or negative. And by using these signed number representations, we can easily perform arithmetic operations with positive and negative numbers to get the right answer.