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 ar
Trang 1Data Representation in Computers/Session 3 / 1 of 45
Data Representation in
Computers
Session 3
Trang 2Session 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
Trang 3Session Objectives (Contd.)
Trang 4Number systems
earlier consisted of symbols e.g
Roman number system - I for 1,
II for 2, III for 3 etc
represent different values depending
on the position they occupy e.g the
Decimal system
Trang 5Decimal Number System
successive position to the left of
the decimal point represent units,
tens, hundreds, thousands etc
its value
therefore are called positional
number system
Base
Position number
(6*10)
Trang 6Decimal 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
Trang 7Binary Number System
and symbols used are 0 and 1
the value of the digit will be two times greater than its predecessor because the base is two
0001111001010111
Least Significant bit Most Significant bit
Binary Number
Trang 8Octal number systems Binary Octal
Trang 9Octal Number System
increase from right to left as 1, 8, 64, 512,
4096
be computed as :
1204 = (1 * 512) + (2 * 64) + (0 * 8) + (4 * 1) = 512 + 128 + 0 + 4
= 644
Trang 10Octal 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:
Trang 11Hexadecimal 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
Trang 12Hex Number Systems(Contd.)
Uses a base of 16
hexadecimal number system obtained
by using the alphabets A, B, C,
D, E and F
decimal equivalent of a hexadecimal
Trang 13Converting binary numbers to decimal
Trang 14 Divide the decimal number by the
base of the required number system
and divide the quotient again with the base
Keep repeating this process until quotient is reduced to a zero
order gives the binary equivalent
Decimal to Binary
Conversion
Trang 15E.g Converting the decimal number 52
to its binary equivalent.
Trang 16Binary 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
Trang 17Binary 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
Trang 18Hexadecimal to
Binary
hexadecimal digit in groups of four
Trang 19Converting 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.
Trang 20Converting from Octal to Binary
Each octal digit is replaced with the appropriate
‘triple’ of binary digits.
Trang 21Binary Concepts
OFF ON
DATA (in binary Digits)
Trang 22printf(“ Hello”);
printf(“We are enjoying a world
of alphabetical coding”);
}
Trang 23Data Representation
Byte is a sequence of 8 bits
consist of 8 or 16 bits
per word could be 16 or 32 bits
Trang 24Data representation
(Contd.)
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
Trang 25 Data is stored and processed in computers in the binary form These symbols 0 and 1, are called bits
i.e 00, 01, 10 , 11
A string of 8 bits is called a byte
Data Storage
Trang 26 During calculation the decimal number
is converted to its binary equivalent.
After calculation the result is converted back to its decimal equivalent.
Data Storage (Contd.)
Trang 27The Packed
Decimal
Packed decimal - data is stored in
a half- way house between pure binary
and one byte per digit
Four bits are required to store all 10
symbols that constitute the decimal
number system
of two decimal digits
Trang 28e.g The number 34 would be stored
in character form as:
Byte 1 Byte 2
00000011 00000100
3 4 Using packed decimal the same number
Trang 29Binary Arithmetic Addition
The following rules of binary addition
Trang 30Complementary
Subtraction
Three steps to perform subtraction :
subtracting
number we are subtracting from
If there is a carry of 1 add the carry to the result of the addition
else
re-complement the sum and attach a negative sign
Trang 31To find the complement of a binary
number invert all the bits
Trang 33Step 2 Add the number you are
Complementary Subtraction
(Contd.)
Trang 34Step 3 Since there is no carry we
re-complement the result and add a negative sign
Thus the answer is -10111001
Complementary Subtraction
(Contd.)
Trang 36Divisio n
1 Start from the left of the dividend
2 Perform subtraction i.e divisor should be subtracted from the dividend
a) if subtraction is possible put 1 in the
quotient and subtract the divisor
from digits of the dividend
else
put 0 in the quotient
b) bring down the next digit to the
right of the remainder
3 Do step 2 till no more digits remain in
the dividend
Trang 37Divisio n
The complete table for binary division is:
0/1 = 0 1/1 = 1 For example:
100001 / 110 Then,
Trang 38Unit of Information
binary numbers to represent letters, special symbols, decimal numbers etc
7 digits are required to uniquely represent all 128 characters
of data between computers
Trang 39ASCI I
Code for Information Interchange (ASCII)
ASCII uses 7 bits per character
possible to provide 128 different
arrangements
end of file, end of page etc to the computer
control characters
internally in personal computers
Trang 40EBCDI C
Interchange Code ( EBCDIC)
using EBCDIC
mainframe models and other similar
machines
Electronic Circuits available to transform characters from ASCII to EBCDIC and
vice- versa
using a computer program
Trang 41An insight into CPU
CPU also referred, as Microprocessor is actually the brain of a computer
There are lot of chips on the motherboard and they all kind of look alike
There are several companies who
manufacture microprocessor chips :
Advanced Micro Devices (AMD),
Cyrix, Intel …
Trang 42CPU Properties
The following are some of CPUs properties:
Trang 43What is meant by CPU speed?
Every computer contains an internal clock that regulates the rate at which each instruction is executed
The clock speed is measured in terms of MegaHertz (MHz)
1 Mhz is equal to 1 million cycles per second Hence a computer with 120 MHz speed means
120 million cycles per second
It must be noted that a faster CPU with less hard disk space would result into a mediocre machine performance.
Trang 44What if I increase the speed of clock?
the speed for which it has been tested and approved is also called as “Overclocking”
faster by setting the jumper on the motherboard But it may cause overheating
damage the chip but the computer would not function properly
Trang 45What is meant by Word Size and
how is it related with speed?
workbenches These workbenches are called as registers
the CPU All data must be represented in the register before it can be processed
each (in terms of bits) determine the speed and performance of the CPU
operation is determined by size of a word