Tải bản đầy đủ (.ppt) (45 trang)

Computer Hardware & Software - Session 3 pps

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (259.83 KB, 45 trang )

Data Representation in Computers/Session 3 / 1 of 45
Data Representation in
Computers
Session 3
Data Representation in Computers/Session 3 / 2 of 45
Session Objectives

Describe what a Number system is

Explain the decimal, octal and hexadecimal
number systems

Convert a number from one number system
to another

Practice binary arithmetic

List the various standard codes used to
represent the unit of information

ASCII

EBCDIC
Data Representation in Computers/Session 3 / 3 of 45
Session Objectives (Contd.)

Explain Data Representation

Explain Data Storage

Explain Packed Decimal



Binary Arithmetic Calculation

Explain CPU and its speed
Data Representation in Computers/Session 3 / 4 of 45
Number
systems

The additive approach - Number
earlier consisted of symbols e.g.
Roman number system - I for 1,
II for 2, III for 3 etc.

Positional numbering - Symbols
represent different values depending
on the position they occupy e.g. the
Decimal system
Data Representation in Computers/Session 3 / 5 of 45
Decimal Number System

In the decimal number system the
successive position to the left of
the decimal point represent units,
tens, hundreds, thousands etc.

(3 * 100) + (6*10) + (5*1) = 365

The position of the number affects
its value.


These kind of number systems
therefore are called positional
number system.
Base
Position number
(6*10)
Data Representation in Computers/Session 3 / 6 of 45
Decimal Number System
(Contd.)

The value of each digit in the
number system is determined by:
a) The digit itself
b) The position of the digit
in the number
c) The base/radix of the system
Data Representation in Computers/Session 3 / 7 of 45
Binary Number System

The binary number system has a base of two
and symbols used are 0 and 1.

In this number system, as we move to the left,
the value of the digit will be two times greater
than its predecessor because the base is two.

Thus the value of the places are :

  64  32  16  8  4  2  1
0001111001010111

Least Significant bit Most Significant bit
Binary Number
Data Representation in Computers/Session 3 / 8 of 45
Octal number
systems
Binary Octal
000 0
001 1
010 2
011 3
100 4
101 5
110 6
111 7

Uses a base of 8

Values increase

from right to left
1, 8, 64, 512
Data Representation in Computers/Session 3 / 9 of 45
Octal Number System

The octal system has the base of 8. The value
increase from right to left as 1, 8, 64, 512,
4096.

The decimal value of an octal number 1204 can
be computed as :

1204 = (1 * 512) + (2 * 64) + (0 * 8) + (4 * 1)
= 512 + 128 + 0 + 4
= 644
Data Representation in Computers/Session 3 / 10 of 45
Octal Number System
Binary Octal
0000
0011
0102
0113
100 4
1015
110 6
111 7

To convert a number from binary to octal and vice
versa, the following table must be kept in mind:
Data Representation in Computers/Session 3 / 11 of 45
Hexadecimal Number
Systems
Hexadecimal Decimal
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8

9 9
A 10
B 11
C 12
D 13
E 14
F 15
Data Representation in Computers/Session 3 / 12 of 45
Hex. Number
Systems(Contd.)

Uses a base of 16

The 16 symbols required for the
hexadecimal number system obtained
by using the alphabets A, B, C,
D, E and F

Converting hexadecimal to decimal
decimal equivalent of a hexadecimal
number A0119
(10 * 65,536)+(0 * 4,096)+(1 * 256)+
( 1 * 16) + ( 9 * 1)
= 6,55,360 + 0 + 256 + 16 + 9
= 6, 55, 641
Data Representation in Computers/Session 3 / 13 of 45
Converting binary numbers to decimal
value
<64 <32 <16 <8 <4 <2 <1
The decimal equivalent of 110100 is

= (1 * 32 ) + (1 * 16) + (0 * 8) +
( 1 * 4) + ( 0 * 2) + (0 * 1)
= 32 + 16 + 0 + 4 + 0 + 0
= 52
Binary to Decimal
Conversion
Data Representation in Computers/Session 3 / 14 of 45

Divide the decimal number by the
base of the required number system

Note the remainder in one column
and divide the quotient again with the base

Keep repeating this process until quotient is
reduced to a zero

Reading remainders in the reverse
order gives the binary equivalent
Decimal to Binary
Conversion
Data Representation in Computers/Session 3 / 15 of 45
E.g. Converting the decimal number 52
to its binary equivalent.
Remainder
2 |__52
2 |__26 | 0
2 |__13 | 0
2 |__06 | 1
2 |__03 | 0

2 |__01 | 1
2 |__00 | 1
Thus the binary equivalent of the decimal
number 52 is 110100
Decimal to Binary
Conversion
Data Representation in Computers/Session 3 / 16 of 45
Binary to
Hexadecimal

Each hexadecimal digit is represented
by 4 binary digits.
Binary Hexadecimal
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F
Data Representation in Computers/Session 3 / 17 of 45

Binary to Hexadecimal
(Contd.)■
Split the quantity into groups of four
outwards from right to left

Each group of four is directly converted into
its hexadecimal equivalent

Add zeros to the left of the number if
necessary

E.g. Binary 10101011000010
Hexadecimal Equivalent
0010 1010 1100 0010
2 A C 2
Data Representation in Computers/Session 3 / 18 of 45
Hexadecimal to
Binary

Write binary equivalent of each
hexadecimal digit in groups of four

E.g. hexadecimal 191A412C
0001 1001 0001 1010 0100 0001 0010 1100

Thus the required binary number can be
written as :
11001000110100100000100101100

The leading zeroes are omitted

Data Representation in Computers/Session 3 / 19 of 45
Converting from Binary to Octal

The binary number must be
divided into groups of three from
the octal point- to the right in case
of the fractional portion and to the
left in case of the integer portion.

Each group can then be replaced
with their octal equivalent.

We may add zero to the left of the
number if required.
For example :
Binary 101010101010100
101 010 101 010 100
5 2 5 2 4

52524 is the octal
equivalent of the given
binary number.
Data Representation in Computers/Session 3 / 20 of 45
Converting from Octal to Binary

For example :

6 5
110 101



Similarly the binary equivalent of
the octal number 65 is 110101.

Each octal digit is replaced with the appropriate
‘triple’ of binary digits.
Data Representation in Computers/Session 3 / 21 of 45
Binary Concepts
OFF
ON
DATA
(in binary Digits)
Data Representation in Computers/Session 3 / 22 of 45
Data Representation
000111
000111010101
011101000110100
101010010 01010
1010101 01001
10010001 001001
0011110 0110100
101010 10010101
101010 1010000
Main()
{
printf(“ Hello”);
printf(“We are
enjoying a world
of alphabetical
coding”);

}
Data Representation in Computers/Session 3 / 23 of 45
Data
Representation

Digital computers use binary code to
represent characters.

Binary code is made up of binary
digits or bits.

A string of "0s" and "1s" is used to
represent characters.

Byte is a sequence of 8 bits.

Most computers have words that
consist of 8 or 16 bits.

In large computers the number of bits
per word could be 16 or 32 bits.
Data Representation in Computers/Session 3 / 24 of 45
Data representation
(Contd.)

When data is keyed in, each keystroke
is converted to a binary character
code and transmitted to the computer

Each character to the printer, screen,

disk is communicated in binary code.

While displaying or printing, the character
is converted back to human readable form

Data Representation in Computers/Session 3 / 25 of 45

Data is stored and processed in computers in
the binary form. These symbols 0 and 1, are
called bits

2 bits give four unique combinations
i.e. 00, 01, 10 , 11.

A string of 8 bits is called a byte

Words are stored one character/byte.
Data
Storage

×