GCSE Computer Science/Binary representation
Specification link Recognise the use of binary numbers in computer systems - 2016 CIE Syllabus p10 |
You already know the denary number system (although you might not have known what it is called). Denary is the number system we use in our everyday lives and has ten numerals: 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. Because it has ten numerals we call it base-10. When writing larger numbers needing more than one numeral each numeral is worth ten times the numeral to its right. In computing we also use the hexadecimal and binary number systems.
In binary we have only two digits 0 and 1 so we call this base-2. Computers as we know them today are electronic machines which at their most basic level are simply a collection of billions and billions of switches which can be either on (represented by the digit 1) and off (represented by the digit 0). For Humans to be able to work with computers we need ways of representing all of the data we use in binary. Everything you see on your computer screen can be converted in to binary so that it can be processed by the computer. In this section you will learn how all numbers, text, pictures, videos and sounds can be represented in binary.
Denary numbers in binaryEdit
In denary if we want to use numbers bigger than 9 we have to start using multiple numerals. Each numeral is worth ten-times the numeral to its right. The number three-thousand, one-hundred and forty is shown in denary in figure 1 below.
This works in a very similar way with binary except that each numeral is worth only two-times the numeral to its right. Here we can see how the number forty would be represented in binary. This is because there are two states 1 and 0 hence the headings are of the powers of 2 starting with 2^0.
ConvertingEdit
Specification link CIE 1.1.1(ii) Convert positive denary integers into binary and positive binary integers into denary (a maximum of 16 bits will be used) - 2016 CIE Syllabus p10 Ed 3.1.3 be able to convert between binary and denary whole numbers (0–255) OCR 2.6(ii-ii) how to convert positive denary whole numbers (0–255) into 8 bit binary numbers and vice versa |
You can convert to and from binary using the following techniques:
Binary to DenaryEdit
- Write out the binary number.
- Write the denary number 1 above the least significant bit (the last digit on the right).
- Write the number 2 above the next most significant bit, then 4 and so on.
- Add together the denary values of all digits given as a 1. Ignore any 0s.
In this example we would add 32 + 8 to find the answer 40.
Example Convert the binary number 100101 in to denary. First we write out the number and assign a denary value to each bit, like this: 32 16 8 4 2 1 1 0 0 1 0 1 Finally we add together all of the values where we have a binary 1, so: 32 4 + 1 --- 37 --- Which gets us the answer of 37. |
Denary to BinaryEdit
- On the right of the page write the denary numeral 1
- To its left right the numeral 2, then 4 and so on doubling each time until you reach a number higher than the one you are trying to convert
- Write a 0 under the most significant bit (the number on the far left). It is too large so we won't use it.
- Move one place to the right, if that number is smaller than the number you're trying to convert then place a 1 under it.
- Whenever you place a 1 under a number subtract that value from your running total
- Continue with step 2 and 3 until you reach the final digit.
Example Convert the denary number 73 in to binary. First I write out the denary place values from right to left: 128 64 32 16 8 4 2 1 I don't need to use the 128 as it is too high, so I write a 0 under it: 128 64 32 16 8 4 2 1 0 I can use the 64, which leaves me with 9 left to make: 128 64 32 16 8 4 2 1 0 1 With only 9 left I don't need the 32 or the 16, but I do need the 8: 128 64 32 16 8 4 2 1 0 1 0 0 1 This leaves me with only 1 left, so I don't need the 4 or the 2: 128 64 32 16 8 4 2 1 0 1 0 0 1 0 0 1 I can see from this that my final answer is 1001001. |
Units of Binary StorageEdit
Specification link Show understanding of the concept of a byte and how the byte is used to measure memory size - 2016 CIE Syllabus p10 |
The smallest unit of data storage possible is a bit (b). The following table shows larger units of measuring data:
Unit | Size | Short form |
---|---|---|
1 bit | A single 1 or 0 | b |
1 nibble | 4 bits | |
1 byte | 2 nibbles | B |
1 kilobyte | 1,024 bytes | KB |
1 megabyte | 1,024 kilobytes | MB |
1 gigabyte | 1,024 megabytes | GB |
1 terabyte | 1,024 gigabytes | TB |
Example Question Dan is at the shop choosing between four different laptops. He knows he will need a laptop with a lot of space to store data. Which of the following laptops has the most disk space? Answer: 1 mark for: Laptop D |
Binary in registersEdit
Specification link Use binary in computer registers for a given application (such as in robotics, digital instruments and counting systems) - 2016 CIE Syllabus p10 |
A register is a group of bits, often represented in a grid. The following grid shows an 8-bit register.
1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 |
Computers (or microprocessors) are used to control devices, such as robots, industrial or household environments. Registers are used as part of the control system. Each bit in the register will control a different part of the system. For example, suppose a microprocessor controls a household security system. The register could be setup as follows:
1 | 0 | 1 | 0 | 1 | 0 | 1 | 1 |
Kitchen light on | Kitchen light off | Kitchen camera on | Kitchen camera off | Sound alarm | Silence alarm | Send notification | Autocall Police |
In this state, the kitchen light would be triggered ON, the camera would be triggered ON, the alarm would be triggered ON, the notification would be sent, and the police would be autocalled. When another register is send to the control system, the state of each part can be changed by adjusting the bits in the register.