Presentation is loading. Please wait.

Presentation is loading. Please wait.

A-Level Computing#BristolMet Session Objectives#9 express numbers in binary, binary-coded decimal (BCD), octal and hexadecimal; describe and use two’s.

Similar presentations


Presentation on theme: "A-Level Computing#BristolMet Session Objectives#9 express numbers in binary, binary-coded decimal (BCD), octal and hexadecimal; describe and use two’s."— Presentation transcript:

1 A-Level Computing#BristolMet Session Objectives#9 express numbers in binary, binary-coded decimal (BCD), octal and hexadecimal; describe and use two’s complement and sign and magnitude to represent negative integers; perform integer binary arithmetic, that is addition and subtraction Create a GCSE calculator using an IF ELSE statement

2 A-Level Computing#BristolMet Binary Arithmetic & BCD Starter: How many binary digits would be required for this hexadecimal code and what is the 8 bit binary equivalent: #FF9B22

3 GCSE Computing#BristolMet Converting Binary to Hexadecimal Denary 45 in binary is 32 + 8 + 4 + 1 or 128 64 32 16 8 4 2 1 0 0 1 0 1 1 0 1 Split into 2 nibbles and treated as 4 bits each: 8 4 2 18 4 2 1 0 0 1 0 1 1 0 1 = 2 = 13 = 2D TASK: Using the same method convert a) 11101011 b) 10100011 Now try the reverse, convert to binary a) A5 b) 3B a) EB b) A3 a) 10100101 b)00111011

4 A-Level Computing#BristolMet Binary Coded Decimal (BCD) Binary Coded Decimal (BCD) uses 4 bit binary to represent decimal digits 0 – 9. You simply split the digits and treat the separately. For example, decimal 75 in BCD is as follows: 7 = 5 = 8 4 2 1 8 4 2 1 0 1 1 10 1 0 1 Therefore 75 in BCD becomes: 01110101 Now convert the following denary into BCD: a)39 b)58 c)97

5 A-Level Computing#BristolMet Binary Arithmetic Another reason why computers are designed to use binary is that addition is so simple in binary. In binary there are only 4 sums which need to be known: 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 0, carry 1 For example;Now try: 75 = 0 1 0 0 1 0 1 1 a) 01101101 + + 01110001 14 = 0 0 0 0 1 1 1 0 0 1 0 1 1 0 0 1 = 89b) 01111000 Carry 1 1 1 + 00110011

6 A-Level Computing#BristolMet Sign & Magnitude So far we have learned how to store positive whole numbers in binary but there is a need to use negative numbers and fractions. You will remember that only 7 bits is need to represent the ASCII character set (127 characters) and this is the purpose of the 8th bit, to represent a +/- For example: +/- 64 32 16 8 4 2 1 +75 = 0 1 0 0 1 0 1 1 -75 = 1 1 0 0 1 0 1 1 This is called sign/magnitude representation – the byte is in 2 parts, the sign (+/-) and the size of the number.

7 A-Level Computing#BristolMet 2s Complement There are 2 problems with sign & magnitude representation. Firstly, the biggest number that can be represented is now halved – 127 instead of 255. Secondly, arithmetic now made more complicated as different bits means different things. A solution to this is using a system called 2s complement – the last bit stands for -128. So the diagram looks like this: -128 64 32 16 8 4 2 1 So -75 in 2s complement is: -128 64 32 16 8 4 2 1 -75 = 1 0 1 1 0 1 0 1

8 A-Level Computing#BristolMet Subtraction in binary Now using 2s complement subtraction is easier because 75 – 14 is the same as 75 + (-14) -128 64 32 16 8 4 2 1 75 = 0 1 1 0 1 0 1 1 -14 = 1 1 1 1 0 0 1 0 0 0 1 1 1 1 0 1 = 61 Carry 1 1 Now attempt a)97 + 23 b) 43 – 58 Some more examples:Click HereClick Here Why binary arithmetic – Watch this videoWatch this video


Download ppt "A-Level Computing#BristolMet Session Objectives#9 express numbers in binary, binary-coded decimal (BCD), octal and hexadecimal; describe and use two’s."

Similar presentations


Ads by Google