Data Representation in Computer Systems
Data Representation in Computer Systems
3
2.2 Data Types
4
Cont….
What is flip-flop?
• Flip-flops are a binary cell or a two state device that stores
only binary numbers(0’s and 1’s)
• Everything a computer does is broken down into a series of
0s and 1s.
5
2.3 Number Systems
6
Cont….
7
Binary Number Systems
01011001 = 89
8
Binary Base 10
Conversion from one base to Another
10
2.4 Complements
11
Cont….
(r’s) complement
•The r’s complement of an n-digit number N in base r is :
•It also obtained by adding 1 to (r-1)’s complement. So
15
Sign-magnitude Representation
17
Cont….
• Example:
Using signed magnitude
binary arithmetic, find the
sum of 75 and 46.
• First, convert 75 and 46 to
binary, and arrange as a sum, but
separate the (positive) sign bits
from the magnitude bits.
18
Cont….
• Example:
Using signed magnitude
binary arithmetic, find the
sum of 75 and 46.
• Just as in decimal arithmetic, we
find the sum starting with the
rightmost bit and work left.
19
Cont….
• Example:
Using signed magnitude
binary arithmetic, find the
sum of 75 and 46.
• In the second bit, we have a
carry, so we note it above the
third bit.
20
Cont….
• Example:
Using signed magnitude
binary arithmetic, find the
sum of 75 and 46.
• The third and fourth bits also
give us carries.
21
Cont….
• Example:
Using signed magnitude binary
arithmetic, find the sum of 75
and 46.
• Once we have worked our way
through all eight bits, we are done.
22
Cont….
• Example:
Using signed magnitude binary
arithmetic, find the sum of 107
and 46.
• We see that the carry from the
seventh bit overflows and is
discarded, giving us the erroneous
result: 107 + 46 = 25.
23
Cont….
24
Cont….
25
One’s Complement Representation
26
Two’s complement representation
27
Cont….
28
Cont….
29
2.6 Other Binary Codes
30
BCD( Binary Coded Decimal)
• There are two types of BCD coding techniques used
before.
a) 4 bits BCD and
b) 6 bits BCD
BCD (4 -bits)
• The 4 bit BCD, which represent any digit of decimal number by four
bits of binary numbers.
• If you want to represent 219 using 4 bit BCD you have to say 0010
0001 1001
BCD(6-bit)
• It uses 6-bits to code a Character (2 for zone bit and 4 for
digit bit)
• It can represent 26 = 64 characters (10 digits, 26 capital 31
characters and some other special characters).
Cont….
34
Cont….
*Unicode
•Both EBCDIC and ASCII were built around the Latin
alphabet, they are restricted in their abilities to provide data
representation for the non-Latin alphabets.
•Is a new international information exchange code.
•Because the base coding of Unicode is 16 bits, it has the
capacity to encode the majority of characters used in every
language of the world.
•Many of today’s systems embrace Unicode, a 16-bit
system that can encode the characters of every language
in the world.
The Java programming language, and some operating systems now
35
use Unicode as their default character code.
2.7 Error Detection and Correction
36
Cont….
37
Cont….
38
Cont….
Arithmetic Modulo 2
•Arithmetic modulo 2 uses two binary operands with no borrows or
carries.
39
Cont….
40
Cont….
41
Cont….
42
Cont….
44
Cont….
45
Cont….
46
Cont….
47
Cont….
48
Cont….
49
Cont….
50
Cont….
51
Cont….
53
Cont….
54
Cont….
55
Cont….
56
Cont….
• Using the Hamming algorithm, we can not only detect single bit errors in
this code word, but also correct them!
57
Cont….
58
Cont….
60