OCR Computing A-Level Revision

Binary (1.3.a)

Binary numbers are similar to decimal numbers. In the same way as each decimal digit is worth 10 times more than the digit to the right of it, each binary digit is worth 2 times more than the digit to the right of it. Also, in the same way as there are 10 possibilities in decimal (0-9), there are 2 possibilities in binary (0 or 1). This is why decimal is known as "base-10", and binary is known as "base-2".

For example, the number "10" would be written as "1010" - 1 eight and 1 two.

8 4 2 1  
1 0 1 0 (10)

The reason computers use binary (and not decimal, octal, or anything else) as their primary number system is because binary is digital - either electricity is flowing (binary 1), or electricity isn't flowing (binary 0).

Binary Negative (1.3.b)

Two's Complement

11001001 can be interpreted as either 201 (using normal binary) or -55 (using two's complement). A question will tell you if it should be read using two's complement.

  1. Firstly, write the number in binary. For example, 54 becomes 00110110 in 8-bit binary.
  2. Then, invert the digits (i.e. 1s become 0s, and 0s become 1s), so 00110110 becomes 11001001.
  3. Finally, add 1 - 11001001 + 00000001 = 11001010.
-128 64 32 16 8 4 2 1  
1 1 0 0 1 0 1 0 (-54)

Sign and Magnitude

Sign and magnitude uses the first bit for the sign (positive - 0, or negative - 1), and the remaining 7 bits for the number. For example, 11001011 represents -75. The first "1" means it is negative, and the remaining 7 bits (1001011) represent 75.

+/- 64 32 16 8 4 2 1  
1 1 0 0 1 0 1 1 (-75)

Binary Addition (1.3.c)

Binary addition is far easier than decimal addition! This is because there are only 4 possible sums - 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, 1 + 1 = 0, carry 1 (or 10, decimal 2). For example:

  128 64 32 16 8 4 2 1  
  0 0 1 0 1 0 1 0 (42)
+ 0 1 1 0 0 1 1 0 (102)
Carry: 1 1   1 1 1      
  1 0 0 1 0 0 0 0 (144)

In an exam you must show your working to show that you didn't just convert the numbers to decimal, and then convert the solution from decimal back to binary.

Binary Subtraction

Binary subtraction can be done in two ways - just like decimal subtraction. You can either do 5 - 3, or -3 + 5 (using twos compliment - not sign and magnitude). Unless a question tells you to use twos compliment, you can use whichever method you prefer.

Using twos compliment:

  -128 64 32 16 8 4 2 1  
  1 1 0 0 1 0 0 0 (-56)
+ 0 1 1 0 0 1 0 1 (101)
Carry: 1 1              
  0 0 1 0 1 1 0 1 (45)

Using subtraction:

  128 64 32 16 8 4 2 1  
  1 0 0 1 0 1 0 0 (148)
- 0 0 1 0 0 1 1 1 (39)
Carry: 0 1 1 0 1 1 0 1 1  
  0 1 1 0 1 1 0 1 (109)