GCSE Computing – Representation of data in computer systems: numbers Candidates should be able to: convert positive denary whole numbers (0-255) into 8-bit binary numbers and vice versa add two 8-bit binary integers and explain overflow errors which may occur convert positive denary whole numbers (0-255) into 2-digit hexadecimal numbers and vice versa convert between binary and hexadecimal equivalents of the same number explain the use of hexadecimal numbers to represent binary numbers. © GCSE Computing Slide 1 Converting 8-bit binary numbers into positive denary whole numbers (0-255) There are 256 different 8-bit binary numbers: 00000000 to 11111111 Each bit represents a different power of 2. Denary equivalent 128 64 32 16 8 4 2 1 Equivalent power of 2 27 26 25 24 23 22 21 20 Binary bits 1 1 1 1 1 1 1 1 One simple method of conversion from binary is therefore to add these powers of 2 for each non-zero bit (1). For example: 128 64 32 16 8 4 2 1 1 0 0 1 1 1 0 1 128 0 0 16 8 4 0 1 8-bit binary 10011101 therefore converts to denary 157 (128 + 16 + 8 + 4 + 1). © GCSE Computing Slide 2 Converting positive denary whole numbers (0-255) into 8-bit binary numbers: method 1 One method is to repeatedly divide the denary number by 2, placing the remainder (0 or 1) below the number and the integer quotient to the left. 1 2 4 9 19 39 78 157 Example 1: 0 0 1 1 1 0 1 157 converts to - 1 Example 2: 156 converts to Example 3: 45 converts to – 1 2 4 9 19 39 78 156 1 0 0 1 1 1 0 0 1 2 5 11 22 45 1 0 1 1 0 1 0 0 Note, the 2 extra 0 bits were added to convert the number into an 8-bit binary number. © GCSE Computing Slide 3 Converting positive denary whole numbers (0-255) into 8-bit binary numbers – method 2 Another method is to repeatedly subtract decreasing powers of 2 from the denary number, starting with 27 (128) . If the result is zero or positive, place 1 below the number, then place the difference to the right. Otherwise place 0 below the number and copy the number to the right. Repeat until you reach 20 (1). 128 64 32 16 8 4 2 1 Example 1: 157 converts to - Example 2: 45 converts to © GCSE Computing 157 29 29 29 13 5 1 1 1 0 0 1 1 1 0 1 128 64 32 16 8 4 2 1 45 45 45 13 13 5 1 1 0 0 1 0 1 1 0 1 Slide 4