Paper 1 - Theory Fundamentals
Paper 2 - Problem Solving & Programming Skills
Paper 3 - Advanced Theory
Paper 4 - Practical Programming
1 of 2

Sign & Magnitude & Two’s Complement

Sign & Magnitude

In computer science there are several ways that we can identify positive and negative numbers the first of which is Sign and Magnitude. Sign and Magnitude simply replaces the most significant bit with the sign much like we would see in the denary number system except instead of adding a symbol we add a 1 or a 0 to represent either positive or negative.

In the example below we know that we have a negative number because there is a 1 in the in significant bit representing the sign. To turn this into a positive number all we need do is simply change the one into a 0.

Sign and Magnitude

Two’s Complement

Unfortunately, Sign and Magnitude is not a very efficient way to represent positive and negative numbers. Two’s Compliment is an alternative way to represent both positive and negative numbers which can then be used in arithmetic operations. You will see Two’s Compliment in use when floating point numbers normalised.

There are several ways in which to convert from denary into a negative Two’s Complement format. However, one particular way is very useful for the exam as it does not rely on a brute force technique and makes use of your prior understanding of how to create a positive binary number. Following the steps in the algorithm below we can transform a positive number into a negative number using the Two’s Complement method:

  • set up the columns with the most significant bit as a minus number
  • convert the positive version of the number into its fixed point binary format
  • identify the least significant one
  • retain the same numbers for the least significant one and any trailing zeros
  • flip all other digits towards the most significant figure
Twos Complement Binary

Of course, don’t trust me and just use my example! Take any negative integer and test this theory out for yourself.