Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.

13
Data Representation S2

Transcript of Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.

Page 1: Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.

Data Representation

S2

Page 2: Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.

This unit covers how the computer represents-

• Numbers• Text• Graphics• Control

Page 3: Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.

Numbers

Our number system is called the Decimal or denary number system. We use the digits 0 to 9 to represent any number.

We use the column headings –

Thousands Hundreds Tens Units

3 2 5

so 325 is made up of 3 hundreds + 2 tens + 5 units

300 + 20+ 5

=325

Page 4: Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.

Computers have their own number system called Binary. They only have 2 digits to represent any number, 0 or 1.

0 = off

1 = on

Each 0 or 1 is called a bit. (binary digit)

In Binary the column headings are –

128 64 32 16 8 4 2 1

Page 5: Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.

Converting a binary number to denary

Example: Convert 0100 0101 to denary

Step 1 – write down column headings

128 64 32 16 8 4 2 1

Step 2 – place binary number under correct heading

128 64 32 16 8 4 2 1

0 1 0 0 0 1 0 1

Step 3 -

Add up all the headings that have a 1 underneath them

64 +4 +1 = 69ten

So, 0100 0101 in denary is 69ten.

Page 6: Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.

Example 2 : Convert 1001 1010 to denary

Step 1 – write down column headings

128 64 32 16 8 4 2 1

Step 2 – place binary number under correct heading

128 64 32 16 8 4 2 1

1 0 0 1 1 0 1 0

Step 3 -

Add up all the headings that have a 1 underneath them

128 +16 +8 +2 = 154 ten

So, 1001 1010 in denary is 154ten.

Page 7: Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.

Convert the following binary numbers to denary

1. 0000 0011

2. 0001 1001

3. 0110 0100

4. 1000 0010

5. 1010 1010

6. 1100 1011

7. 1110 0011

8. 1111 0010

1. 3ten

2. 25ten

3. 100ten

4. 130ten

5. 170ten

6. 203ten

7. 227ten

8. 242 ten

Page 8: Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.

Convert the following decimal numbers to binary

1. 12

2. 25

3. 47

4. 63

5. 88

6. 106

7. 201

8. 254

1. 0000 1100

2. 0001 1001

3. 0010 1111

4. 0011 1111

5. 0101 1000

6. 0110 1010

7. 1100 1001

8. 1111 1110

Page 9: Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.

HOW TEXT IS STORED IN A COMPUTER

A binary code is used to represent each character. The code used most often is known as the American Standard Code for Information Interchange – or ASCII.

CHARACTER – any symbol or letter on the computer keyboard e.g. c, G, 2, 9, $ are all characters

BYTE – a binary code which is made up of eight bits; a byte is used to represent one character.

Page 10: Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.

Examples of ASCII codes:

CHARACTER CODE

R 01010010

m 01101101

% 00100101

+ 00101011

The word “Hello” would be stored as:

H 01001000

e 01100101

l 01101100

l 01101100

o 01101111

Page 11: Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.

Representing Graphics

Graphics (pictures) on the computer screen are made up of tiny dots called pixels.

Each pixel may be “on” or “off” depending on whether the value of the pixel in memory is 1 or 0.

Page 12: Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.

               

               

               

               

               

               

               

               

 0 0  0 0 0 0 0 0

0 1  1 1 1 1 0  0

 0 0  0 1   0  0  0 0 

 0  0  0 1 0  0  0 0 

 0 0   0 1  0 0 0 0

 0 0  0 1  0 0 0 0

 0 0   0  0  0 0 0 0

 0 0  0  0  0  0  0  0 

By writing in the place values above each box, we can calculate the numbers the computer would need to store to be able to show the graphic on screen.

Page 13: Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.

 0 0  0 0 0 0 0 0

0 1  1 1 1 1 0  0

 0 0  0 1   0  0  0 0 

 0  0  0 1 0  0  0 0 

 0 0   0 1  0 0 0 0

 0 0  0 1  0 0 0 0

 0 0   0  0  0 0 0 0

 0 0  0  0  0  0  0  0 

128 64 32 16 8 4 2 1

= 0

=64+32+16+8+4=124

=16

=16

=16

=16

=0

=0

For the computer to show this graphic on screen, the following numbers

0, 124, 16, 16, 16, 16, 0, 0 have to be stored in memory.