07 Transforming Data Into Information - Part I
07 Transforming Data Into Information - Part I
2
How Computers Represent Data
– Number System
• Computer processing is performed by transistors,
which are switches with only two possible states: on
and off.
3
Ten different
symbols in
the decimal
system
Numbers
above 9
use more than
1 digit
Number System Base 10 Base 2
0 0
1 1
• To convert data into strings of
numbers, computers use the binary 2 10
number system. 3 11
10 1010
5
How Computers Represent Data
- Bits and Bytes
• A single unit of data is called a bit, having a value of 1 or
0.
• Numbers used - 0, 1, 2, 3, 4, 5, 6, 7.
Number System
- Hexadecimal Number System
• Numbers used - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
"A", "B", "C", "D", "E" and "F".
Base Conversion Table
Convert From Any Base To Decimal
• Let’s consider the decimal number 1234
1 2 3 4
• In a octal number
… 8^3=512 8^2=64 8^1=8 8^0=1
Example : Binary to Decimal
1 0 0 1
1 0 0 1 . 0 1
2 3 4
2 3 4 . 1 4
10)1234
10)123 -4
10)12 -3
10)1 - 2 -------------
0 -1
Integer part = 1 0 1 0 0 1 1 1 1 0 12
Example: Decimal to Binary contd…
Fractional part (Base 2 : Binary)
0.0 1 0 0 1 1 0 …
0.3*2 = 0.6 0 ---
0.6*2 =1.2 1 ------
0.2*2 =0.4 0 --------
0.4*2 =0.8 0 ----------
0.8*2 =1.6 1 -------------
0.6*2 =1.2 1 ----------------
0.2*2 =0.4 0 ----------------------
1341.3 (Dec)= 10100111101.0100110… (Binary)
Example: Decimal to Octal
8)1341
8)167 -5
8)20 - 7 --------------
8)2 - 4 ----------
0 - 2 ------
2 4 7 5 (Base 8 : Octal)
Example: Decimal to Hexadecimal
16)1341
16)83 - 13 --------------
16)5 - 3 ----------
0 - 5 ------
5 3 D (Base 16 : Hex)
Example: Decimal to Hexadecimal contd…
• Integer part
16)3315
16)207 - 3 --------------
16)12 - 15 ----------
0 - 12 ------
C F 3 (Base 16 : Hex)
Example: Decimal to Hexadecimal cnt…
a) 3D59
b) 27.A3C
28
Hexadecimal-Binary Interconversion
29
Binary-Hexadecimal Interconversion
a) 10110101
b) 110101110001100
c) 100111.101011
30
Representing Negative Numbers
0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1
8 – BIT Representation
Sign-Magnitude Notation
• As its name implies, a sign-magnitude representation
records the number’s sign and magnitude.
• The most significant bit is 0 for positive numbers and
1 for negative numbers.
• The rest of the bits are set as usual.
Example:-
Find
1) -59
2) -20
3) -25
Sign-Magnitude Notation contd…
34
One’s Complement Notation
Example:-
Example
Method 1:
18 = 0001 0010
one’s complement = 1110 1101
+1
two’s complement of 18 = 1110 1110 = -18
Method 2:
18 = 00010010
two’s complement of 18 = 1110 1110 = -18
Two’s Complement contd…
Decimal Two’s Complement
7 0111
6 0110
5 0101
4 0100
3 0011
2 0010
1 0001
0 0000
−1 1111
−2 1110
−3 1101
−4 1100
−5 1011
−6 1010
−7 1001
−8 1000
Two’s Complement contd…
Example:-
Suppose you are working with 8-bit values.
Convert into binary and use two’s complement
method to find
59 - 32
Two’s Complement contd…
43