We know how to represent a positive denary number in binary.
But what about negative numbers?
How does a computer program know that a number is positive or negative?
The answer is that the number will be arranged with a sign bit. The sign bit will tell us if the number is positive or negative.
To represent negative number in binary there are 3 steps:
for example, let's represent the denary number -13 as an 8-biit 2's complement binary integer:
| 0-128 | 064 | 032 | 016 | 18 | 14 | 02 | 1 1 |
| 1 -128 | 164 | 132 | 116 | 08 | 04 | 12 | 01 |
| 1-128 | 164 | 132 | 116 | 08 | 04 | 12 | 11 |
Now we have -13 represented in binary.
Here is a nice video explaining the concept.
Now we know that the most significant bit in a 2's complement number represents -128, it is easy for us to convert 2's complement numbers to denary (decimal).
Have a look at this example and take some paper and a pen and work it out. Then, click the answer button!
| 1-128 | 064 | 132 | 016 | 18 | 04 | 02 | 11 |
Click on the Exercises tab and complete as many as you can.
2's complement is a technique that allow's us to work with negative numbers in binary. All we need to do is create a sign bit. With 8 bits, the biggest number we can create is 255. But now, the most significant bit is a sign bit. What is the biggest number we can create using 7 bits of data and a sign bit?
big data cite consumer visualize quote target reputable bibliograpy predict static ubiquitous trends live