Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 29

WEEK -9

2
Continue……….

How Computers Represent Data

• Computers work with binary • A bit is either “on” or “off,” a 0 or a 1.


numbers, which include only 0s and
1s. • Eight bits, a byte, signify a single unit
of storage.
• The smallest piece of data that a
computer can work with is known as a
bit.

• The common measurement of a modem’s data transfer rate is in bits per second,
such as gigabits per second (Gbps).

• The common measurement of data storage is in bytes, such as gigabytes (GB).

Zafar Iqbal Khan 4 Application of ICT


Continue……….

How Computers Represent Data

Zafar Iqbal Khan 5 Application of ICT


Continue……….

How Computers Represent Data

• Because even small numbers require many digits when converted to binary,
computers convert binary numbers into hexadecimal (hex) numbers, which
use the numbers 0 through 9, followed by letters A through F.

Zafar Iqbal Khan 6 Application of ICT


Continue……….

Adding Numbers in Binary

Zafar Iqbal Khan 7 Application of ICT


Continue……….

Subtraction with base 2 Numbers

Zafar Iqbal Khan 8 Application of ICT


Convert the Binary Number into Decimal

Example
To convert the Binary Number (101.01) into Decimal.
1 0 1. 0 1
    
22 21 20 2-1 2-2
= 1 x 22 + 0 x 2 + 1 + 0 x 2-1 + 1 x 2-2

4+ 0+ 1 +0 + 1/22 = 5.25
(101.01)2  (5.25)10
Zafar Iqbal Khan 9 Application of ICT
Convert the Decimal Number into Binary

Integer Remainder Coefficient


Example for (13)10: Quotient

13/2 = (12+1)½ a0 = 1
6/2 = ( 6+0 )½ a1 = 0
3/2 = (2+1 )½ a2 = 1
1/2 = (0+1) ½ a3 = 1

Answer (13)10 = (a3 a2 a1 a0)2 = (1101)2

Zafar Iqbal Khan 10 Application of ICT


Convert the Decimal Number into Binary

Example for (0.625)10:


Integer Fraction Coefficient
0.625 x 2 = 1 + 0.25 a-1 = 1
0.250 x 2 = 0 + 0.50 a-2 = 0
0.500 x 2 = 1 + 0 a-3 = 1

Answer (0.625)10 = (0.a-1 a-2 a-3 )2 = (0.101)2

Zafar Iqbal Khan 11 Application of ICT


(Example) (41.6875)10 (?)2
Integer = 41, Fraction = 0.6875
Overflow Fraction
Integer remainder X by 2 .6875
Closer to
41 /2 1 . 1 .3750
the point
20 0 0 .750
10 0 1 .5
5 1 1 0
2 0
1 1

The first procedure produces


41= 1 x 25 + 0 x 24 + 1 x 23 + 0 x 22 + 0 x 2 + 1 = (101001)
0.6875=0.1011
41.6875 (10) = 101001.1011 (2)
Zafar Iqbal Khan 12 Application of ICT
Convert the Octal Number into Decimal

• Octal numbers (Radix or base=8) are made of octal digits:


(0,1,2,3,4,5,6,7)

• How many items does an octal number represent?

• Convert the following octal number to decimal


(465.27)8 = 4x82 + 6x81 + 5x80 + 2x8-1 + 7x8-2

Zafar Iqbal Khan 13 Application of ICT


Convert the Octal Number into Decimal

Example for (175)10:


Integer Remainder Coefficient
Quotient
175/8 = 21 + 7/8 a0 = 7
21/8 = 2 + 5/8 a1 = 5
2/8 = 0 + 2/8 a2 = 2

Answer (175)10 = (a2 a1 a0)2 = (257)8

Zafar Iqbal Khan 14 Application of ICT


Convert the Decimal Number into Octal
Example for (0.3125)10:
Integer Fraction Coefficient

0.3125 x 8 = 2 + 0.5 a-1 = 2


0.5000 x 8 = 4 + 0 a-2 = 4
Answer (0.3125)10 = (0.24)8

Combine the two (175.3125)10 = (257.24)8


Remainder Overflow of
of division multiplication

Zafar Iqbal Khan 15 Application of ICT


Hexadecimal Numbers

• Hexadecimal numbers are made of 16 symbols:


– (0,1,2,3,4,5,6,7,8,9,A, B, C, D, E, F)
• Convert a hexadecimal number to decimal
– (3A9F)16 = 3x163 + 10x162 + 9x161 + 15x160 = 1500710
• Hexadecimal with fractions:
– (2D3.5)16 = 2x162 + 13x161 + 3x160 + 5x16-1 = 723.312510
• Note that each hexadecimal digit can be represented
with four bits.
– (1110) 2 = (E)16
• Groups of four bits are called a nibble.
– (1110) 2
Zafar Iqbal Khan 16 Application of ICT
Hexadecimal Numbers
Example

 Convert the decimal number (107.00390625)10 into hexadecimal


number.

Integer remainde Overflow Fraction


r X by 16 .
Closer to 00390625
107 Divide/16 .
the period 0 .0625
6 11=B
0 6 1 .0000

 (107.00390625)10  (6B.01)16
Zafar Iqbal Khan 17 Application of ICT
The Growth of Binary Numbers
n 2n n 2n
0 20=1 8 28=256
1 21=2 9 29=512
2 22=4 10 210=102
3 23=8 4
4 2 =16
4 11 211=204
8
5 25=32
12 212=409
6 2 =64
6
6
7 27=128
20 220=1M Mega
30 230=1G Giga
40 240=1T Tera
Zafar Iqbal Khan 18 Application of ICT
Conversion Between Number
Bases
Octal(base 8)

Decimal(base 10) Binary(base 2)

Hexadecimal
(base16)
° We normally convert to base 10
because we are naturally used to the
decimal number system.
° We can also convert to other number
systems
Zafar Iqbal Khan 19 Application of ICT
One to one comparison

• Binary, octal, and


hexadecimal similar
• Easy to build circuits to
operate on these
representations
• Possible to convert
between the three
formats

Zafar Iqbal Khan 20 Application of ICT


Converting between Base 16 and Base 2

3A9F16 = 0011 1010 1001 11112


3 A 9 F
° Conversion is easy!
 Determine 4-bit value for each hex digit
° Note that there are 24 = 16 different values of
four bits which means each 16 value is
converted to four binary bits.
° Easier to read and write in hexadecimal.
° Representations are equivalent!

Zafar Iqbal Khan 21 Application of ICT


Converting between Base 16 and Base 8

3A9F16 = 0011 1010 1001 11112


3 A 9 F

352378 = 011 101 010 011 1112


3 5 2 3 7
1. Convert from Base 16 to Base 2
2. Regroup bits into groups of three starting from right
3. Ignore leading zeros
4. Each group of three bits forms an octal digit (8 is represented
by 3 binary bits).

Zafar Iqbal Khan 22 Application of ICT


Example
Convert 101011110110011 to
a. octal number
b. hexadecimal number

a. Each 3 bits are converted to octal :


(101) (011) (110) (110) (011)
    
5 3 6 6 3
101011110110011 = (53663)8
b. Each 4 bits are converted to hexadecimal:
(0101) (0111) (1011) (0011)
   
5 7 B 3
101011110110011 = (57B3)16
Conversion from binary to hexadecimal is similar except that the bits divided into
groups of four.

Zafar Iqbal Khan 23 Application of ICT


Binary Subtraction
• We can also perform subtraction (with borrows).
• Example: subtract (10111) from (1001101)

1+1=
2
1 10 borrows
0 10 10 0 0 10

1 0 0 1 1 0 1
- 1 0 1 1 1
------------------------
0 1 1 0 1 1 0
(1001101)2 - (10111)2 = (0110110)2
Zafar Iqbal Khan 24 Application of ICT
Binary Addition

Example Add (11110)2 to


(10111)2

1 1 1 1 1 1 carries
1 1 1 1 0 1
+ 1 0 1 1 1
---------------------
1 0 1 0 1 0 0
carry
(111101)2 + (10111) 2 = (1010100)2
Zafar Iqbal Khan 25 Application of ICT
Prove right hand side equal to left
hand site by using truth table

a. A B = AB’ + A’B
A B A B AB’ A’B AB’ + A’B

0 0 0 0 0 0

0 1 1 0 1 1

1 0 1 1 0 1
1 1 0 0 0 0

Zafar Iqbal Khan 26 Application of ICT


Prove right hand side equal to left
hand site by using truth table

b. BC’ = ABC’ + A’BC’


A B C BC’ ABC’ A’BC’ ABC’+A’BC’
0 0 0 0 0 0 0
0 0 1 0 0 0 0
0 1 0 1 0 1 1
0 1 1 0 0 0 0
1 0 0 0 0 0 0
1 0 1 0 0 0 0
1 1 0 1 1 0 1
1 1 1 0 0 0 0

Zafar Iqbal Khan 27 Application of ICT


[1]. Graham Brown and David Watson, " Information and Communication Technology ” 2013.

[2]. Peter Norton, “Introduction to Computers” 6th International Edition (McGraw Hill)

[3]. Charles S. Parker, " Understanding Computer Today & Tomorrow”, 2000.

You might also like