You are on page 1of 24

Chapter Three

Data Representation and computer arithmetic

Jimma University Technology Institute


Faculty of Computing and Informatics
Muluken Yohannis (MSc)
05/06/22 1
Outline
 Number system
 Computer arithmetic
 Data representations in computers
 Coding methods

05/06/22 2
Data Representation
Types of Data
Text
Image
Audio
Video
Number

05/06/22 3
Text
 Text is series of characters.
 In computer, each character is represented by bit pattern. This
process is called coding.
 Data are coded when they enter a computer and decoded when
they are presented to user .
 The number of bits for each character is depending on number
of characters.
 There are several codes had been used these days:

05/06/22 4
Image
 There are two methods to represent an image in computer:
 Bitmap graphic
▪ An image is divided into dots.
▪ Each dot is called pixel. And its size depend on the screen resolution.
▪ Each pixel is represented with bit pattern.
▪ The size of the pit pattern is depend on the color mode.
▪ If the image made of only black & white dots, one bit pattern is enough .
▪ If the image is full-colored (RGB mode) it use three bit pattern for each pixel:
one for red color intensity, one for blue color intensity and one for green color
intensity.
▪ We can’t resize bitmap image without loosing its quality.
 Vector graphic
▪ An image is decomposed into curves and lines.
▪ Each curve and line is represented using mathematical formulas .
▪ We can resize vector image and keeping its quality .
05/06/22 5
Audio
 Sound variation curve is divided into equal intervals orsamples.
(Sampling)
 Each sample is given a non-fractional value. (Quantization)
 Each value is represented in binary pattern. (Coding)

Video
 Video is series of images (or frames). Each frame is stored as
normal image.

Numbers
 They are represented using binary system (0’s and 1’s).

05/06/22 6
Number System
Decimal Binary Octal Hexadecim
al

No of 10 2 8 16
digits
(base)
Example (34)10 (00100010)2 (42)8 (22)16

05/06/22 7
Decimal Number System
 Name
“decem” (Latin) => ten

 Characteristics
Ten symbols
0123456789
Positional
3945 ≠ 3495
• 3945 = (3*103) + (9*102) + (4*101) + (5*100)
05/06/22 8
Binary Number System
 Name
“binarius” (Latin) => two
 Characteristics
Two symbols
01
Positional
0110B ≠ 1100B
Most (digital) computers use the binary number
system
 Terminology
Bit: a binary digit
Byte: (typically) 8 bits
05/06/22 9
Decimal -Binary Equivalence
Decimal Binary
0 0
1 1
2 10
3 11
4 100
5 101
6 110
7 111
8 1000
9 1001
10 1010
05/06/22 10
Decimal- binary conversion
 Conversion steps:
 Divide the number by 2.
 Get the integer quotient for the next iteration
 Get the remainder for the binary digit.
 Repeat the steps until the quotient is equal to 0.

05/06/22 11
Cont’d…
 Example :Convert (13)10 to binary

Division by 2 Quotient Remainder


13/2 6 1
6/2 3 0
3/2 1 1
1/2 0 1

Answer (1101)2

05/06/22 12
Binary to Decimal Conversion
For binary number with n digits:

dn-1 ... d3 d2 d1 d0
The decimal number is equal to the sum of binary
digits (dn) times their power of 2 (2n)

decimal = d0×20 + d1×21 + d2×22 + ...

05/06/22 13
Cont’d
Example: Find the decimal value of 1110012:

binary number: 1 1 1 0 0 1

power of 2: 25 24 23 22 21 20

1110012 =

1*25+1*24+1*23+0*22+0*21+1*20 = 5710

05/06/22 14
Octal Number system
 Name
“octo” (Latin) => eight
 Characteristics
Eight symbols
01234567
Positional
1743O ≠ 7314O
Computer programmers often use the octal number
system

05/06/22 15
Decimal-Octal Equivalence
Decimal Octal
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 10
9 11
10 12
05/06/22 16
Octal to Decimal
 Count the number of digits present in the given number. Let
the number of digits be ‘n’.
 Now multiply each digit of the number with 8n-1, when the
digit is in the nth position from the right end of the number.
If the number has a decimal part, multiply each digit in the
decimal part by `8-m` when the digit is in the mth position
from the decimal point.
 Add all the terms after multiplication.
 The obtained value is the equivalent decimal number.

05/06/22 17
Cont’d
 Example :Convert 418 to a decimal

Solution: Given number is 418

418 = (4 * 81) + (1 * 80)

=4*8+1*1

= 32+1

= (33)10
05/06/22 18
Hexadecimal Number system
Name

“hexa” (Greek) => six

Characteristics

Sixteen symbols
0123456789ABCDEF
Positional
• A13H ≠ 3A1H
Computer programmers often use the hexadecimal number system
05/06/22 19
Decimal-Hexadecimal Equivalence
Decimal Hexadecimal Decimal Hexadecimal
0 0 11 B
1 1 12 C
2 2 13 D
3 3 14 E
4 4 15 F
5 5 16 10
6 6 17 11
7 7 18 12
8 8 19 13
9 9 20 14
10 A 21 15

05/06/22 20
Hexadecimal to Decimal
 Multiply each digit of the hex number with its
corresponding power of 16 and sum:

 Decimal = dn-1×16n-1 + ... + d3×163 + d2×162 +

d1×161+d0×160

 Example: 3B in base 16 is equal to each digit


multiplied with its corresponding 16n:
 (3B)16 = 3×161+11×160 = 48+11 = 5910
05/06/22 21
05/06/22 22
Question & Answer

05/06/22 23
Thank you!

05/06/22 24

You might also like