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.

TH
Answered by Tim H. Computing tutor

9094 Views

See similar Computing GCSE tutors

Related Computing GCSE answers

All answers ▸

How would you check if a number is palindrome using a looping algorithm in any programming language ?


Describe the diference between an object and a class


In terms of programming software, what is a translator? Describe the differences between the following three translators: assembler, compiler, interpreter.


i) Convert 01101001 from binary to denary. ii) Convert 27 from denary to hexadecimal. ii) State one use of hexadecimal in computing and why it is more beneficial in this application that binary.


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–2025

Terms & Conditions|Privacy Policy
Cookie Preferences