Académique Documents
Professionnel Documents
Culture Documents
Section 2.0
Encode as 101100010010011
Model Information
Data
© 2009, University of Colombo School of Computing 5
Bit Storage - Capacitor
1 2 3
Can store 1
of 2 possible
states
plates discharging plates discharged
8 Bits = 1 Byte
Octal System
¾ Alphabet = { 0,1,2,3,4,5,6,7 }
Hexadecimal System
¾ Alphabet = { 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F }
Binary System
¾ Alphabet = { 0,1 }
7 6 5 4 3 2 1 0
7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2
Decimal value
Bit position
7 6 5 4 3 2 1 0
128 64 32 16 8 4 2 1
Decimal value
Example:
Convert the unsigned binary number 10011010 to
decimal
1 0 0 1 1 0 1 0
7 6 5 4 3 2 1 0
1 0 0 1 1 0 1 0
7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2
7 6 5 4 3 2 1 0
1 0 0 1 1 0 1 0
128 64 32 16 8 4 2 1
7 6 5 4 3 2 1 0
1 0 0 1 1 0 1 0
128 64 32 16 8 4 2 1
128 + 16 + 8 + 2 = 154
So, 10011010 in unsigned binary is 154 in
decimal
Example:
Convert the decimal number 105 to unsigned
binary
A. No
7 6 5 4 3 2 1 0
0
128 64 32 16 8 4 2 1
Next, consider the difference: 105- 0*128 = 105
A. Yes
7 6 5 4 3 2 1 0
0 1
128 64 32 16 8 4 2 1
Next, consider the difference: 105- 1*64 = 41
A. Yes
7 6 5 4 3 2 1 0
0 1 1
128 64 32 16 8 4 2 1
Next, consider the difference: 41- 32 = 9
Decimal System
¾ 0,1,2,3,4,5,6,7,8,9,10,11,12,13……
Binary System
¾ 0,1,10,11,100,101,110,111,1000,1001,1010,1011
,1100,1101…...
Decimal System
¾ 0,1,2,3,4,5,6,7,8,9,10,11,12,13……
Hexadecimal System
¾ 0,1,,2,3,4,5,6,7,8,9,A,B,C,D,E,F,10,11,12,13,14,15,
16,17,18,19,1A,1B,1C,1D,1E,1F…...
• 100101102
• 1001 0110
• 1001 0110
• 9 6
100101102 = 96 Hexadecimal
• 110110112
• 1101 1011
• 1101 1011
• D B
110110112 = DB Hexadecimal
•00101001 11101012
• 00101001 11110101
• 0010 1001 1111 0101
2 9 F 5
• E.g.
1 0 1 1
¾ x 1 0 1 0
¾ 0 0 0 0
¾ + 1 0 1 1
¾ + 0 0 0 0
¾ + 1 0 1 1
¾ = 1 1 0 1 1 1 0
• 1 for negative
Sign bit
¾ 0 1 1 1 1 1 1 1 = +127
¾ .
¾ .
¾ 0 0 0 0 0 0 1 1 = +3
¾ 0 0 0 0 0 0 1 0 = +2
¾ 0 0 0 0 0 0 0 1 = +1
¾ 0 0 0 0 0 0 0 0 = 0
¾ 1 1 1 1 1 1 1 1 = -1
¾ 1 1 1 1 1 1 1 0 = -2
¾ 1 1 1 1 1 1 0 1 = -3
¾ .
¾ 1 0 0 0 0 0 0 1 = -127
¾ 1 0 0 0 0 0 0 0 = -128
© 2009, University of Colombo School of Computing 57
Two’s Compliment benefits
7 * 10-3 = 7/1000
5 * 10-2 = 5/100
3 * 10-1 = 3/10
6 * 100 = 6
1 * 101 = 10
• 7/
1000 + /100
5 + 3/10 + 6 + 10 = 16 357/1000
1 * 2-3 = 1/8
1 * 2-2 = 1/4
0 * 2-1 = 0
0 * 20 = 0
1 * 21 = 2
• 1/
8 + 1/4 + 2 = 2 3/8
• i.e. 10.011 = 2 3/8 in Decimal (Base 10)
1 * 2-4 = 1/16
0 * 2-3 = 0
1 * 2-2 = 1/4
0 * 2-1 = 0
1 * 20 = 1
1 * 21 = 2
0 * 22 = 0
• 1/
16 + 1/4 + 1 + 2 = 3 5/16
RADIX POINT
MANTISSA
EXPONENT
SIGN
00
00
00 00 00 11 00
00 00 00 11 00
00 00 11 11 00 00 11 00
11
11
11 11 00 11 00
11 11 11 00 11
11 11 00 00 11 11 00 11
00
00
00 00 11 11 00
00 00 00 00 11 00 11 11
1 0 1 1 1 0 1 0
0 1 1 3-3=0
1 0 1 1 1 0 1 0
1 1 0 1 0
1 0 1 1 1 0 1 0
1 0 1 1 1 0 1 0
0 0 0 1 0 1
0 0 0 1 0 1
0 0 0 1 0
0 0 0 1 0
0 1 0 0 0 0 1 0
0 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1
1.111111 × 2127
+ 1.111111 × 2127
11.111110 × 2127
1.1111110 × 2128 =∞
© 2009, University of Colombo School of Computing 120
Floating Point Underflow
10.010000 × 2-126
÷ 11.000000 × 20
0.110000 × 2-126
1.100000 × 2-127 =0
© 2009, University of Colombo School of Computing 121
Floating Point Representation:
Double Precision