Module 1.
Computer Fundamentals
Prof. Datta Deshmukh
Assistant Professor
K.J. Somaiya Institute of Technology , Sion
Decimal number system:
• Base/Radix = 10
• 10 distinct elements = {0,1,2,3,4,5,6,7,8,9}
• Digit position is weighted by power of '10'
• Example: (235.7)10 = (2×102) + (3×101) + (5×100) + (7×10-1)
Binary number system:
• Base/Radix = 2, only 2 elements {0,1}
• Digit position is weighted by power of '2'
• Example: (110.01)2=(1×22) + (1×21) + (0×20) + (0×2-1) + (1×2-2)
Octal number system:
• Base/Radix = 8, hence total 8 elements in the system
{0,1,2,3,4,5,6,7}
• Digit position is weighted by power of '8'
• Example: (54.36)8 = (5×81) + (4×80) + (3×8-1) + (6×8-2)
Hexadecimal number system:
• Base/Radix = 16, hence total 16 elements in the system
{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}: A to F corresponds to 10 to 15
• Digit position is weighted by power of '16'
• Example: (A5.7C)H = (10×161) + (5×160) + (7×16-1) + (12×16-2)
Base-3 number system:
• Base/Radix = 3, hence only 3 elements {0,1,2}
• Digit position is weighted by power of '3'
• Example: (120.02)3=(1×32) + (2×31) + (0×30) + (0×3-1) + (2×3-2)
For integer (57)10
57 ÷ 2 = 28 remainder 1
28 ÷ 2 = 14 remainder 0
14 ÷ 2 = 7 remainder 0
7÷2=3 remainder 1
3÷2=1 remainder 1
1÷2=0 remainder 1
For fractional part (0.3125)10
0.3125 × 2 = 0.625 integer 0
0.625 × 2 = 1.25 integer 1
0.25 × 2 = 0.5 integer 0
0.5 × 2 = 1.0 integer 1
1. Divide the decimal number by 'N' Decimal (Base-10) to Binary
2. Write the integer quotient & remainder (Base-2)
on right side
3. Use the new quotient & perform step-1
& 2 repeatedly, till the quotient becomes
'0'
4. Collect all the remainders in “Bottom-up”
manner
5. Rewrite result: (Number)10 = (Number)N
Hence (57)10 = (111001)2
1. Multiply the fractional part by 'N' (0.3125)10 into Binary (Base-2)
2. Write the Product of this multiplication & has 2
parts:
- Integer part to the left side of decimal point
- Fractional part to the right side of decimal point
3. Use the new fractional part & perform step-1 & 2
repeatedly, till the product becomes '0'
Hence, (0.3125)10 = (0.0101)2
4. Collect all integers in “Top-down” manner
5. Rewrite the result as: (Number)10 = (Number)N
Note: For real decimal (containing integer & fractional
part), results to be concatenated
Hence, (57.3125)10 = (111001.0101)2
For integer (169)10
169 ÷ 8 = 21 remainder 1
21 ÷ 8 = 2 remainder 5
2 ÷ 8 = 0 remainder 2
For fractional part (0.28)10
0.28 × 8 = 2.24 integer 2
0.24 × 8 = 1.92 integer 1
0.92 × 8 = 7.36 integer 7
0.36 × 8 = 2.88 integer 2
0.88 × 8 = 7.04 integer 7
0.04 × 8 = 0.32 integer 0
Operation is unending,hence stop after 6 to 7 steps
Hence, (169.28)10 = (251.217270)8
For integer (379)10
379 ÷ 16 = 23 remainder 11= B
23 ÷ 16 = 1 remainder 7
1 ÷ 16 = 0 remainder 1
For fractional part (0.02)10
0.02 × 16 = 0.32 integer 0
0.32 × 16 = 5.12 integer 5
0.12 × 16 = 1.92 integer 1
0.92 × 16 = 14.72 integer 14 = E
0.72 × 16 = 11.52 integer 11 = B
0.52 × 16 = 8.32 integer 8
Operation is recurring hereafter, hence stop
Therefore, (379.02)10 = (17B.051EB8)H
For integer (33)10
33 ÷ 3 = 11 remainder 0
11 ÷ 3 = 3 remainder 2
3 ÷ 3 = 1 remainder 0
1 ÷ 3 = 0 remainder 1
For fractional part (0.45)10
0.45 × 3 = 1.35 integer 1
0.35 × 3 = 1.05 integer 1
0.05 × 3 = 0.15 integer 0
0.15 × 3 = 0.45 integer 0
Here, the sequence is recurring, hence stop
Hence, (33.45) = (1020.1100)
• Simply add the weights together
• Rewrite the decimal equivalent number
Conversion of (120.02)3 into decimal
(120.02)3 = (1×32) + (2×31) + (0×30) + (0×3-1) + (2×3-2)
= 9 + 6 + 0 + 0 + 0.22
= (15.22)10
Conversion of (A5.7C)H into decimal
(A5.7C)H = (10×161) + (5×160) + (7×16-1) + (12×16-2)
= 160 + 5 + 0.44 + 0.05
= (165.49)10
Conversion of Binary (1101.01)2 to Base-5 system
Step 1: Binary to decimal. Hence (1101.01)2 = (13. 25)10
Step 2: Decimal to Base-5. Perform by successive division by 5
to 13, & successive multiplication by 5 to 0.25
Hence, (1101.01)2 = (13.25)10 = (23.111111)5
Conversion of Binary (Base-2) to Octal (Base-8)
Above method can be used, as it is “Universal”
But, follow the shortcut as Octal = Base '8' = 23
View binary in groups of 3 bit & express the groups in octal by
adding {4,2,1} weightages where logic'1' is present
(10110.01)2 =(010 110 . 010)2 :Complete groups of 3 bits each
( 2 6 . 2 )8
Conversion of Octal (Base-8) to Binary (Base-2)
“Universal” method is: Octal to Decimal to Binary
But, follow the shortcut method as Octal = Base '8' = 23
Expand each Octal digit in group of three binary bits in {4:2:1}
manner: ( 1 7 5 . 2 6)8
(001 111 101 . 010 110)2
Remove the redundant '0's and rewrite the result.
Hence, (1111101.01011)2
Conversion of Binary (Base-2) to Hex (Base-16)
Hexadecimal Base = 16 = 24
View binary in groups of 4 bit & express the groups in Hex by
adding {8,4,2,1} weightages where logic '1' is present
Example: Convert (1010111001.011011)2 to Hex
0010 1011 1001 . 0110 1100
Hex Result = ( 2 B 9 . 6 C )H
Hex to Binary conversion
Expand the hex digit in 4 bit binary using {8,4,2,1} weightages
(2AC.78)H = (0010 1010 1100. 0111 1000)2
Hence, binary after removing redundant '0's:
(2AC.78) = (10 1010 1100. 0111 1)
• Decimal digits expressed in 4 bit binary form using {8,4,2,1} weightages
Binary: Operating number system of Digital computers
Decimal: Natural number system that human understands easily
• Advantages of both number system are collected together in BCD
• BCD is also referred as 8421-BCD (as it is weighted)
Decimal BCD Decimal BCD
0 0000 1 0001
2 0010 3 0011
4 0100 5 0101
6 0110 7 0111
• Excess-3 (XS-3) is extension of BCD: adds (3)10 to the BCD value
• BCD is weighted (8421), but XS-3 is Non-weighted, Inverted Reflected code
Decimal 8421-BCD XS-3 code
0 0000 0011
1 0001 0100
2 0010 0101
3 0011 0110
4 0100 0111
5 0101 1000
6 0110 1001
7 0111 1010
8 1000 1011
• Non-weighted, n-bit code (not restricted to only 4 bits like BCD
or XS-3 code)
• Reflected code except the MSB (left most bit)
• Differs only at 1 bit position from the previous combination
Decimal to 2 bit Binary to Gray code conversion:
Decimal Binary Gray code
0 00 00
1 01 0
2 10 1
3 11 10
Successive Gray code entries differ only at 1 bit:
00 → 01→ 11→ 10
Note: Above reflect plane, MSB = 0 & below plane, MSB = 1
(lower bits are the true reflections about the plane)
Step 1: Write 2 bit Gray code in Step 2: Append MSB = 0 above plane,
sequence & reflect all entries below '1' below & rewrite the 3 bit Gray code
00 3 bit Gray
01 000
11
001
10
011
Reflect plane
10 010
11 110
01 111
00 101
Consider binary input: 10010
Gray output in bit by bit is:
G4 = B4 = 1
G3 = 1 (as '1' & '0' are Ex-OR i/ps)
G2 = 0 (as '0' & '0' are Ex-OR i/ps)
G1 = 1 (as '0' & '1' are Ex-OR i/ps)
G0 = 1 (as '1' & '0' are Ex-OR i/ps)
Hence, Gray output = 11011
Consider Gray input: 10101
Binary output in bit by bit is:
B4 = G4 = 1
B3 = 1 (as '1' & '0' are Ex-OR i/ps)
B2 = 0 (as '1' & '1' are Ex-OR i/ps)
B1 = 0 (as '0' & '0' are Ex-OR i/ps)
B0 = 1 (as '0' & '1' are Ex-OR i/ps)
Hence, Binary output = 11001
Problem:
The gray code is “10010. 01101”. Convert it into Octal, BCD & Excess-3 code.
Solution hints:
Octal: First convert gray code into Binary without consideration of the binary point,
but inserting the binary point at last & then this binary converted into Octal
Binary: (11100. 01001)2
Octal: (34. 22)8
BCD: Binary or octal obtained is converted into decimal & then into BCD (Octal is
preferred over binary as it is fast)
Decimal: (28. 28)10
BCD: 0010 1000 . 0010 1000
Excess-3: Decimal obtained is converted into the Excess-3
Excess-3: 0101 1011 . 0101 1011
Problem statement:
Convert the decimal number (163.13)10 into Binary, Octal, Hexadecimal,
Ternary, BCD, Excess-3 & Gray code.
Solution hints:
Decimal to Binary: Using “Double-Dabble method” on decimal number
Octal: Using short cut method (making the groups of 3 binary bits &
expressing them in octal)
Hexadecimal: Making groups of 4 binary bits & expressing them in Hex
Ternary: Using “Ternary-Dabble method” on given decimal number
BCD: Expressing each decimal digit of given number in 4 bit binary form
Excess-3: Add '3' to each decimal digit & express sum in 4 bit binary form
Gray code: Converting the binary directly into Gray code using “Binary to
Gray code conversion logic” explained earlier
Given decimal number: (163.13)10
• Binary: (10100011. 00100001)2
• Octal: (243. 102)8
• Hex: (A3. 21)H
• Ternary: (20001. 0101112)3
• BCD: 0001 0110 0011. 0001 0011
• Excess-3: 0100 1001 0110. 0100 0110
• Gray: 11110010. 10110001
• Inverter/NOT gate using NAND:
• AND gate using NAND:
• OR gate using NAND:
• NOR gate using NAND: • Ex-OR gate using NAND:
• Inverter/NOT gate using NOR:
• OR gate using NOR:
• AND gate using NOR:
NAND gate using NOR: Ex-OR gate using NOR:
Computer Architecture Computer Organization
- Defines the parameters/attributes - Defines the attributes which are invisible/
visible to the programmer non-available to the programmer
- Architecture includes: - Organization includes:
Instruction set, No. of bits, Control signals, Interfacing methods,
Data transfer mechanisms etc. Details of control unit designs etc.
- Includes simply the instructions - Includes the methods to implement
that instruction
- Remains same for many years - Architecture has many organizational
like IBM PC, Apple Mac etc. models with different price and
performance characteristics
Von-Neumann (Princeton) Harvard
- Common memory for - Separate memory
Program & Data
- No protection amongst - Natural protection
Program & Data
- Simple, Inexpensive - Complex & Costly H/W
Hardware
- Complex O.S. - Simple O.S.
- Less execution speed - Higher execution speed