Download presentation
Presentation is loading. Please wait.
Published byElmer Barber Modified over 9 years ago
1
Chapter 4: Representation of data in computer systems: Number OCR Computing for GCSE © Hodder Education 2011
2
Denary Numbers can be expressed in many different ways. We usually use decimal or denary. Denary numbers are based on the number 10. We use ten digits: 0,1,2,3,4,5,6,7,8,9. When we put the digits together, each column is worth ten times the one to its right. OCR Computing for GCSE © Hodder Education 2011
3
Denary So, the denary number 1234 is OCR Computing for GCSE © Hodder Education 2011 Place value 1000100101 Digit1234 Place valueDigitValue 100011 × 1000 =1000 1002+ 2 × 100 =200 103+ 3 × 10 =30 14+ 4 × 1 =4 TotalΣ =1234
4
Binary to denary It is simpler to make machines that only need to distinguish two states, not ten. That is why computers use binary numbers. OCR Computing for GCSE © Hodder Education 2011 1286432168421 Each column is worth twice the column to it right. 1286432168421 00000010 Add up the columns that have a 1 on them. In this case it is 2. 1286432168421 10001111 In this case it is 128 + 8 + 4 + 2 + 1 = 143.
5
Denary to binary One technique is to take the denary number and repeatedly divide by 2. Write down the result and the remainder. For example, find the denary number 147: Read from the bottom up: 147 in binary is 10010011. OCR Computing for GCSE © Hodder Education 2011 ResultRemainder 147 ÷ 2 =731 73 ÷ 2 =361 36 ÷ 2 =180 18 ÷ 2 =90 9 ÷ 2 =41 4 ÷ 2 =20 2 ÷ 2 =10 1 ÷ 2 =01
6
Binary addition The rules for binary addition: 0 + 0 = 0 0 + 1 = 1 1 + 1 = 0 carry 1 1 + 1 + 1 = 1 carry 1 Add the binary equivalents of denary 4 + 5 (we know this equals 9). OCR Computing for GCSE © Hodder Education 2011 DenaryBinary 40100 50101 91001 Carry1
7
Binary addition Sometimes we run into problems. Suppose we have eight bits in each location. Add the binary equivalent of denary 150 + 145. We know this equals 295. No room for a carry so it is lost and we get the wrong answer. When there isn’t enough room for a result, this is called overflow and produces an overflow error. OCR Computing for GCSE © Hodder Education 2011 DenaryBinary 15010010110 14510010001 29500100111 Carry11
8
Hexadecimal numbers Programmers often write numbers down in hexadecimal (hex) form. Hexadecimal numbers are based on the number 16. They have 16 different digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F Each column is worth16 times the one on its right. OCR Computing for GCSE © Hodder Education 2011 256161
9
Hexadecimal numbers We can convert denary numbers to hexadecimal by repeated division just as we did to get binary numbers. Take the denary number 141. We have the hexadecimal values 8 and 13 as remainders. 13 in hexadecimal is D. So, reading from the bottom again (where necessary), 141 in hexadecimal is 8D. OCR Computing for GCSE © Hodder Education 2011 ResultRemainder 141 ÷ 16 =813
10
Hexadecimal to denary All we do is multiply the numbers by their place values and add them together. For example, take the hexadecimal number 4F. 64 + 15 = 79 So, 4F is 79 in denary. OCR Computing for GCSE © Hodder Education 2011 Place value256161 Hex digits04F Denary= 0 × 256= 4 × 16= 15 × 1 = 0= 64= 15
11
Binary to hexadecimal This is particularly easy. Simply take each group of four binary digits, starting from the right and translate into the equivalent hex number. OCR Computing for GCSE © Hodder Education 2011 Binary11110011 HexF3
12
Hexadecimal to binary Do the reverse. You may find it easier to go via denary. Treat each hex digit separately. OCR Computing for GCSE © Hodder Education 2011 HexDB Denary1211 Binary11011011
13
Why use hexadecimal? Each hex digit represents four binary digits exactly. This makes it a useful shorthand way for programmers to write numbers. This saves effort and reduces the chance of making mistakes. OCR Computing for GCSE © Hodder Education 2011
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.