1 / 8

# Session Objectives #9 - PowerPoint PPT Presentation

Session Objectives #9. Binary Arithmetic & BCD. Starter: How many binary digits would be required for this hexadecimal code and what is the 8 bit binary equivalent: #FF9B22. Converting Binary to Hexadecimal. Denary 45 in binary is 32 + 8 + 4 + 1 or 128 64 32 16 8 4 2 1

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' Session Objectives #9' - yates

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Binary Arithmetic & BCD

Starter:

How many binary digits would be required for this hexadecimal code and what is the 8 bit binary equivalent:

#FF9B22

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 1 8 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

### 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:

39

58

97

### 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 = 89 b) 01111000

Carry 1 1 1 + 00110011

### 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 101 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.

### 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

### 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 10 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

97 + 23

b) 43 – 58