27 we need to add what is called a sign bit to represent +/- (0 (dim) for positive 1 (un) for negative (positif/negyddol), this is added to the far left of our binary number. ▪ So right now our (positive) 27 including the sign bit looks like this:
get our two’s complement is to flip all the bits, if it’s a 0 change it to a 1 and vice versa. ▪ So now our 27 with the added sign bit and bits flipped is:
1 to our binary number, this is then our two’s complement of 2710 ▪ Here you can see the most significant bit (farthest left) has changes to a 1 (or minus)
▪ To get -16 we add a sign bit, 010000 ▪ Flip the bits 101111 ▪ …and add one 110000 ▪ Then add the two numbers together using our binary addition rules: Binary addition rules: 0 + 0 = 0 0 + 1 =1 1 + 1 = 0 and carry 1 1+1+1 = 1 and carry 1 1000 110000 111000 This represents our negative answer (sign bit = 1)
▪ This lesson has shown you how we represent negative numbers in binary. ▪ You now also know how computers can do subtraction using twos complement and binary addition. Lesson +’s Lesson –’s