Digital Computer Principles Binary to Decimal:
Unit I
1) (1101.1011)2 = (?)10
Number conversions:
Decimal to Binary:
1) (25)10 = (?)2
Ans: (1101.1011)2 = (13.6875)10
Questions:
2) (1110101.10101)2 = (?)10
3) (10101.1111)2 = (?)10
4) 20 = 1, 21 = 2, 22 = 4, 23 = 8, 24 = ….., 25 = .….,
2-1 = 0.5, 2-2 = 0.25, 2-3 = ….., 2-4 = …..
Decimal to Octal:
1) (225.225)10 = (?)8
Ans: (25)10 = (11001)2
2) (0.59375)10=(?)2
Ans: (225.225)10 = (341.16314)8
Questions:
2) (1239.567)10 = (?)8
3) (567.1234)10 = (?)8
4) Digits of Decimal system : {0,1,2,3,4,5,6,7,8,9}
Digits of octal system : ………..
5) Base/Radix (i.e, No. of digits) of decimal system is 10
and that of octal system is ……..
Octal to Decimal:
Ans: (0.59375)10=(0.10011)2 1) (253.64)8 = (?)10
3) (25.59375)10 = (11001.10011)2
Questions:
4) (324.75)10 = (?)2 Ans: (253.64)8 = (171.8125)10
5) (86.127)10 = (?)2 Questions:
6) Digits of Decimal system : {0,1,2,3,4,5,6,7,8,9} 2) (172.4)8 = (?)10
Digits of Binary system : ……….. 3) (77.65)8 = (?)10
7) Base/Radix (i.e, No. of digits) of decimal system is 10 4) 80 = 1, 81 = 8, 82 = 64, 83 = …….
and that of binary system is …….. 8-1 = 0.125, 8-2 = …..
Decimal to Hexadecimal: Hexadecimal to Binary:
1) (374.37)10 =(?)16 1) (7A5)16 = (?)2
7 A 5
0111 1010 0101
Ans: (7A5)16 = (011110100101)2
Ans: (374.37)10 =(176.5EB8)16
Questions: Binary to Hexadecimal:
2) (98.567)10 = (?)16
3) (567.1234)10 = (?)16 1) (110100011)2 = (?)16
4) Digits of Decimal system : {0,1,2,3,4,5,6,7,8,9} 0001 1010 0011
Digits of hexadecimal system : ……….. 1 A 3
5) Base/Radix (i.e, No. of digits) of decimal system is 10 Ans: (10100011)2 = (1A3)16
and that of hexadecimal system is ……..
Octal to Hexadecimal:
Hexadecimal to Decimal:
1) (173)8 = (?)16
1) (54.D2)16 = (?)10 1 7 3
001 111 011
1111011
0111 1011
7 B
Ans: (173)8 = (7B)16
Hexadecimal to Octal:
1) (7B)16 = (?)8
Ans: (54.D2)16 = (84.8203)10
7 B
Questions:
0111 1011
2) (1E9.567)16 = (?)10
1111011
3) (C7.A1)16 = (?)10
001 111 011
4) 160 = 1, 161 = 16, 162 = 256, 163 = …….
1 7 3
16-1 = ….., 16-2 = …..
Ans: (7B)16 = (173)8
Misc. Questions:
Octal to Binary:
1) Convert the hexadecimal number 64CD to
binary, and convert it from binary to octal.
1) (705)8 = (?)2
2) Which is wrong with respect to binary system:
7 0 5
(i) 1010 (ii) 0 (iii) 2 (iv) 10 (v) 1
111 000 101
3) Which is wrong with respect to octal system:
Ans: (705)8 = (111000101)2
(i) 1010 (ii) 0 (iii) 2 (iv) 10 (v) 9
4) Which is wrong with respect to decimal system:
(i) A (ii) 0 (iii) 2 (iv) 10 (v) 1
Binary to Octal:
5) Which is wrong with respect to hexadecimal system:
(i) 1010 (ii) H (iii) A (iv) 10 (iv) E
1) (10100011)2 = (?)8
6) Generally, the humans use ……. and the
010 100 011
computers use ……. for processing.
2 4 3
(i) hex, oct (ii) dec, hex (iii) dec, oct
Ans: (10100011)2 = (243)8
(iv) dec, bin (v) dec, dec (vi) bin, bin
Binary Codes: Gray Code:
Binary Coded Decimal (BCD): It is sometimes convenient to use the Gray code
shown in the table to represent digital data that
The code most commonly used for the decimal digits is have been converted from analog data.
the straight binary assignment. This scheme is called
binary‐coded decimal and is referred to as BCD. A
number with k decimal digits will require 4k bits in BCD.
Decimal 396 is represented in BCD with 12 bits as 0011
1001 0110, with each group of 4 bits representing one
decimal digit.
A decimal number in BCD is the same as its equivalent
binary number only when the number is
between 0 and 9. A BCD number greater than 10 looks
different from its equivalent binary number, even
though both contain 1’s and 0’s.
The advantage of the Gray code over the straight binary
Moreover, the binary combinations 1010 through 1111
number sequence is that only one bit in the code group
are not used and have no meaning in BCD.
changes in going from one number to the next.
Consider decimal 185 and its corresponding value in BCD For example, in going from 7 to 8, the Gray code changes
and binary: (185)10 = (0001 1000 0101)BCD = (10111001)2 from 0100 to 1100. Only the first bit changes, from 0 to
1; the other three bits remain the same. But, with binary
The BCD value has 12 bits to encode the characters of numbers the change from 7 to 8 will be from 0111 to
the decimal value, but the equivalent binary number 1000, which causes all four bits to change values.
needs only 8 bits. The representation of a BCD number
needs more bits than its equivalent binary value. • This is a non-weighted code
• It is not suitable for arithmetic operations
There is an advantage in the use of decimal numbers, • It is cyclic
because computer input and output data are generated
• Successive code differs in one-bit position only
by people who use the decimal system.
• Good for error detection.
BCD numbers are decimal numbers and not binary
numbers, although they use bits in their representation.
The only difference between a decimal number and BCD
is that decimals are written with the symbols 0, 1, 2, …..,
9 and BCD numbers use the binary code 0000, 0001,
0010, ….., 1001. The decimal value is exactly the same.
Decimal 10 is represented in BCD with eight bits as 0001
0000 and decimal 15 as 0001 0101. The corresponding
binary values are 1010 and 1111 and have only four bits.
• The digits of a decimal number are encoded
into groups of binary digits
• It is a weighted code
• The weights attached are 8,4,2,1
• Advantages: Ease of conversion
• Disadvantage:
Less efficient than pure binary
• Invalid are:
1010,1011,1100,1101,1110,1111
Excess-3 (XS-3) code Error detecting and Error correcting codes
• It is a non weighted code • When data transmitted through a channel, due to
• The binary code word of it is noise they may be get corrupted
(8421) + 3 • Error detection and correcting codes are used to
• Eg: 5= 0101 + 0011 = 1000 detect and correct errors
• Encoding may be done for ED and EC.
• The invalid states are:
• Eg: Parity code, Hamming code
0000,0001,0010,1101, 1110 &1111
ASCII
(American standard Code for Information Interchange) Error Detecting Code (Parity)
• Alphanumeric Code • The simplest technique for detecting errors
• 7-bit, plus a parity bit for error detection • Implemented by adding an extra bit to
each word being transmitted
(odd/even parity).
• Odd Parity – Set to a 0 or a 1 such that the
• 27 or 128 characters supported
total number of 1’s in the word including the
parity bit is an odd number
Character ASCII Code • Even Parity - Set to a 0 or a 1 such that the
0 0110000 total number of 1’s in the word including
1 0110001 the parity bit is an even number
......
9 0111001
: 0111010 7-bit Hamming Code (Error correcting)
A 1000001 • Three parity bits are added to transmit four
B 1000010 data bits
...... • Parity is added at bit positions
Z 1011010 20 (1), 21 (2) and 22 (4)
[ 1011011 • The word formed is
\ 1011100 P1 P2 D3 P4 D5 D6 D7
• D’s are data bits and P’s are parity bits
EBCDIC • P1 is set to 0 or 1, so that it establishes
(Extended Binary Coded Decimal Interchange code) even parity over the bits
1, 3, 5, 7 (P1, D3, D5, D7)
• It is an 8-bit alphanumeric code
• P2 is set to 0 or 1, so that it establishes
• It can be used to encode all the symbols even parity over the bits
and control characters 2, 3, 6, 7 (P2, D3, D6, D7)
• 28 or 256 characters supported • P4 is set to 0 or 1, so that it establishes
even parity over the bits
Boolean Algebra: 4, 5, 6, 7 (P4, D5, D6, D7)
Logic Gates: NAND Gate
The output is logic 0 only when each of the
Basic Gates: inputs assumes a ‘1’
It is NOT of AND.
NOT Gate
A NOT gate accepts one input value
and produces one output value
If the input value for a NOT gate is 0, the
output value is 1, and if the input value is 1, NAND realization:
The NAND gates are essentially the opposite of
the output is 0 the AND gates
A NOT gate is sometimes referred to as an Basic gates can be implemented by NAND
inverter because it inverts the input value
AND Gate
It accepts two or more input signals
If the input values for an AND gate are 1,
the output is 1; otherwise, the output is 0
It resembles multiplication
NOR Gate
The output is logic 1 only when each of the
inputs assumes a ‘0’
It is NOT of OR.
OR Gate
OR gate has two or more inputs
If all input values are 0, the output value is
0; otherwise, the output is 1
It resembles addition
NOR realization:
The NOR gates are essentially the opposite of
the OR gates
Basic gates can be implemented by NOR
Universal Gates:
❖ The gate that can be used to realize logic
circuits single handedly.
❖ The gates NAND and NOR are called
universal gates
Exclusive-OR (XOR) Gate Exercises:
◼ An XOR gate produces ‘0’ if its two inputs are 1) Implement XOR using NAND.
the same, and a ‘1’ otherwise 2) Implement XOR using NOR.
3) Implement XNOR using NAND.
4) Implement XNOR using NOR.
5) Implement NOR using NAND.
6) Implement NAND using NOR.
Realization of Logic Expression
• It is possible to implement the logical function
using the combination of logic gates.
XOR function: • Example:
Exclusive-NOR (XNOR) Gate
◼ An XNOR gate produces ‘1’ if its two inputs are
the same, and a ‘1’ otherwise
• Example:
XNOR function:
Logic Gates:
Exercises:
Sum of Products (SOP) and minterms
F = x’y’ + x’y + xy’ + xy → SOP
F = m0 + m1 + m2 + m3 → minterms
1) Expand A’+B’ to minterms:
Product of Sums (POS) and maxterms
F = (X+Y)(X+Y’)(X’+Y)(X’+Y’) → POS
F = M0 . M1 . M2 . M3 → maxterms
1) Expand A(B’+A)B Exercises:
1 term: A=A+BB’=(A+B)(A+B’)
2 term: =(B’+A)
3 term: B=B+AA’=(B+A)(B+A’)
A(B’+A)B=(A+B)(A+B’) (B’+A) (B+A)(B+A’)
Eliminating Redundant terms
=(A+B) (A+B’) (A’+B)
=(00)(01)(10) =M0,M1,M2
π M(0,1,2)
1’s and 2’s complements:
• the 1’s complement of a binary number is
formed by changing 1’s to 0’s and 0’s to 1’s.
• The following are some numerical examples:
The 1’s complement of 1011000 is 0100111.
The 1’s complement of 0101101 is 1010010.
• the 2’s complement can be formed by leaving all
least significant 0’s and the first 1 unchanged
and replacing 1’s with 0’s and 0’s with 1’s in all
other higher significant digits.
• For example,
The 2’s complement of 1101100 is 0010100
The 2’s complement of 0110111 is 1001001
Exercises:
Obtain the 1’s and 2’s complements of the
following binary numbers:
(a) 00010000 (b) 00000000 (c) 11011010
(d) 10101010 (e) 10000101 (f) 11111111
F = Σ (1,3,6,7)
= π (0,2,4,5)