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

7515 Views

See similar Computing GCSE tutors

Related Computing GCSE answers

All answers ▸

Why are certain fields chosen to be the primary key in a database?


how do you convert binary to a form in which you can perform subtraction?


Show how you would calculate 53 + 39 in 8-bit binary?


What are 'pointers'?


We're here to help

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

© MyTutorWeb Ltd 2013–2024

Terms & Conditions|Privacy Policy
Cookie Preferences