What is two's complement, and how do I calculate it?

Two's complement is one way negative numbers can be represented in Binary. In Decimal notation, we use a + or - sign to indicate whether it is a postive or negative number respectivly. Two's complement is a little different. Normally, each digit in your binary number will represent (from right to left) 1, 2, 4, 8, 16... In two's complement, we make that left most digit represent the negative value instead - for example 1, 2, 4, 8, -16. We can still represent positive numbers in exactly the same way - 01100 is still 12 (8+4), 00010 is still 2. But we can also represent a negative number, using the -16. 10000 would therefore represent -16 (the smallest number we can write) and 10110 would represent -10 (-16 + 4 + 2). This gives us a nice way of calculating the "two's complement" of a given number - you invert all the digits and add 1 - inverting the digits of 01100 gives 10011 and adding 1 gives 10100, which is -12 (-16+4). We can also quickly check if a number is positive or negative by looking at the most significant (left most) bit - if it's a 0, the number is a positive number, if it's a 1 the number is negative.

Answered by Tim H. Computing tutor

8016 Views

See similar Computing GCSE tutors

Related Computing GCSE answers

All answers ▸

State the denary representation of the binary number 10010111


What is the purpose of RAM in a computer?


What is the difference between data verification and data validation?


How do you convert between 11B (Base-16) to Base-8?


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo
Cookie Preferences