The term digital in digital circuits is derived from the way circuits perform operations by counting digits. A digital circuit operates with binary numbers, i.e., only in two states. The outputs of the circuit is either low or high in a positive logic system. In general, represents zero volts and represents five volts. If the situation is in reverse, it is known as negative logic system.
The decimal number system , is commonly used even though there are many other number systems like binary, octal and hexadecimal, etc. It is possible to express a number in any base or radix . In the binary system, the base is . In general, any number system with radix, , having digits to the left, and digits to the right of the decimal point can be expressed as:
Decimal to binary conversion can be perfomed using the divisor-remainder method, by dividing the decimal number with 2 progressively, until 0 is achieved as a quotient. Further, all the remainder after each division is written in a reverse order, which forms the binary number.
41
to binary equivalent.Divisor-remainder method:
2[41]
2[20]-----1
2[10]-----0
2[5]------0
2[2]------1
2[1]------0
[0]------1
Therefore the binary equivalent is: 101001
.
In case of numbers with decimal point, the part beyond the decimal point is multiplied with 2 untill a loop is achieved. The part of the result before the decimal point, is the binary part, and the part after is then multiplied with two and the process is repeated until a loop is achieved.
41.56
from decimal to binary.For the part before the decimal: 41
2[41]
2[20]-----1
2[10]-----0
2[5]------0
2[2]------1
2[1]------0
[0]------1
The binary equivalent for before the decimal point is: 101001
.
For the part after the decimal, 0.56
, we have:
(0.56)2=1.12-----1
(0.12)2=0.24-----0
(0.24)2=0.48-----0
(0.48)2=0.96-----0
(0.96)2=1.92-----1
The binary equivalent for the part after the decimal is: 10001
.
Therefore the binary equivalent for 41.56
is: 101001.10001
.
The binary number is first numbered starting from zero from right to left, fashion. Then binary digit is multiplied with 2 raised to the power of the position. Lets say, the binary is , and the position is , then the value at that position is:
110010
from binary to decimal.Firstly numbering the binary number:
Pos: 5 4 3 2 1 0
Num: 1 1 0 0 1 0
Therefore, the decimal equivalent is:
Octal number system, is a base 8 number system, which has numbers from .
Hexadecimal number system, is a base 16 number system, consisting of both numbers and digits, , and .
Just like binary, other number systems have the same conversion relations with decimal numbers. When converting from decimal, the divisor-remainder method is used, with the divisor being the base of the required number system. When converting to decimal, the positional number, is multiplied with base raised to the power of position.
Perform the following conversions:
224
[from base 10 to base 16]B2D.F6
[from base 16 to base 10]4C2.E6
[from base 16 to base 2]10110.10110
[from base 2 to base 16]Convert 4447
from octal to hexadecimal using the divisor-remainder method.
Since, base cannot be , therefore the base is .
Following is the chart for binary addition:
First number | Second number | Result |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 10 (0 carry 1) |
26
in binary is: 11010
, 22
in binary is: 10110
.
1 1 1 1
1 1 0 1 0
+ 1 0 1 1 0
-------------------
1 1 0 0 0 0
Therefore, the binary equivalent for the result is: 110000
.
Following is the chart for binary subtraction:
First number | Second number | Result |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 borrow 1 |
1 | 0 | 1 |
1 | 1 | 0 |
10110
from 11010
.
1 1 0 1 0
+ 1 0+1 1 1 0
-------------------
0 0 1 0 0
Therefore the binary equivalent for the result is: 100
.
Older circuits used differnet components for addition and subtraction. Newer circuts demand more functionality in lesser space. Therefore, subtraction is performed by adding the negative of the minuant, to the subtrahend.
For example, in older circuits, is performed normally by deducting from . But in case of modern binary subtractions, the above operation will be performed as:
Converting the minuant to negative form has two methods:
To find the 1'S compliment of a binary number, invert it, i.e., convert 0 to 1 and 1 to 0. For example,
1001011: (1'S) = 0110100
Steps to perform binary subtraction using 1'S compliment:
45 - 25
, using binary subtraction using 1'S method.45 when converted to binary gives, 101101
. Now 25 gives, 11001
, but we will add a zero before the number, to account for the carry as the larger number has 6 binary digits. Therefore, 25 will be written as 011001
.
Now subtracting:
First finding the 1'S compilemnt of the negative number:
25 = 011001
(-25) = 100110
Second adding 45 and (-25):
45 : 101101
(-25): 100110
---------
Res : |1|010011
Now since the carry appears, we will add the carry with the LSB of the result:
010011
+1
------
010100
The final result is 010100
, which in decimal equivalent is 20
. The final result matches the answer.
52-49+25
using binary techniques.Conversion to binary equivalents:
52: 110100
49: 110001 :: (-45): 001110
25: 011001
Addition of 52 and (-49):
52 : 110100
(-49): 001110
---------
Res : |1|000010
Addition of the carry to the LSB:
000010
+1
------
000011
Addition of the first part with 25:
Res: 000011
25 : 011001
------
Res: 011100
Therefore, the final result is, 011100
, which in decimal equivalent is 28
, which matches the final answer.
In binary numbers:
MSB (most significant bit) denotes sign, i.e., 1 for negative, and 0 for positive.
E.g.:
Binary | Sign | 1'S | Decimal |
---|---|---|---|
000 | + | 000 | +0 |
001 | + | 001 | +1 |
010 | + | 010 | +2 |
011 | + | 011 | +3 |
100 | - | 011 | -3 |
101 | - | 010 | -2 |
110 | - | 001 | -1 |
111 | - | 000 | -0 |
As you can see, there are 2 representation of zero, i.e., +0 and -0, which is mathematically not possible. As a result this serves as a major disadvantage of 1'S compliment.
In order to perform 2'S compliment, invert the binary number, and add 1 to LSB.
E.g.: The binary number is 1001
, then its 2'S compliment will be 0110 + 1 = 0111
.
Steps to perform binary subtraction using 2'S compliment:
54 - 47
, using 2'S compliment.Converting decimal numbers to binary numbers:
54 : 110110
47 : 101111
(-47): 010000
+1
------
010001
Now adding, 54+(-47)
:
54 : 110110
(-47): 010001
---------
Res : |1|000111
We will discard the carry, and the final answer is: 000111
, which is equivalent to 7
, in decimal format.
47 - 54
, using 2'S compliment.Converting decimal numbers to binary numbers:
47 : 101111
54 : 110110
(-54): 001001
+1
------
001010
Adding 47+(-54)
:
47 : 101111
(-54): 001010
---------
Res : |0|111001
Since the carry is zero, therefore the answer is negative.
Performing 2'S compliment to get the final result:
111001:: (2'S): 000110 + 1 = 000111
Therefore, the final binary result is: 000111
, and since the binary was negative, the answer is: -7
in decimal forms.
When both the numbers are negative and after binary addition, the MSB is
1
, consider the result negative irrespective of the carry. 2'S compliment the result to get the full result.
E.g.: (-13)-11
-13:: (2S) = 10010 + 1 = 10011
-11:: (2S) = 10100 + 1 = 10101
Adding:
-13 : 10011
-11 : 10101
---------
Res : |1|01000
2'S Complimenting the result, we have:
01000:: (2'S) = 10111 + 1 = 11000
The final result is 11000
in negative, which is -24
, and matches the desired result.
In BCD, each number is represented seperately by binary numbers. For 2-digited numbers, the digits are written in seperate decimal numbers.
Decimal | Binary | BCD |
---|---|---|
0 | 0000 | 0000 |
9 | 1001 | 1001 |
10 | 1010 | 0001 0000 |
15 | 1111 | 0001 0101 |
Steps to perform BCD addition:
0110
, to make it a valid BCD number.248
and 173
using BCD addition.Converting the numbers into BCD form, and adding
248: 0010 0100 1000
173: 0001 0111 0011
--------------
Res: 0011 1011 1011
But, 1011
is more than 9, therefore adding it with 0110
:
Pre: 0011 1011 1011
Fix: 0000 0110 0110
--------------
Res: 0100 0010 0001
--------------
Dec: 4 2 1
Therefore the final result is: 0100 0010 0001
, when using BCD converted to decimal, gives: 421
.
Steps to perform, BCD subtraction:
C | +ve | -ve |
---|---|---|
1 | 0000 | 1010 |
0 | 1010 | 0000 |
1010
if unmarked. If EAC is 0, the result is negative, then 1'S compliment it and follow the above table and add 1010
if marked.127 - 73
using BCD technique.Converting the numbers into BCD:
127 : 0001 0010 0111
73 : 0000 0111 0011
(-73): 1111 1000 1100
Adding 127
and -73
:
127 : 0001 0010 0111
(-73): 1111 1000 1100
--------------
Res : |1|0000 1011 0011 (EAC present)
+1
--------------
Pre: 0000 1011 0100
Fix: 0000 0110 0000
--------------
Res: 0000 0101 0100
--------------
Dec: 0 5 4
Therefore, the result is: 54
.
When arranging in binary code, the corresponding numebers might have more than one digit changed. This makes it difficult to predict, and identify anomalies. Hence Gray code was introduced, as in gray code, all corresponding numbers have only one digit that changes, thereby making it easier to understand anomalies.
Decimal | Binary | Gray |
---|---|---|
0 | 000 | 000 |
1 | 001 | 001 |
2 | 010 | 011 |
3 | 011 | 010 |
4 | 100 | 110 |
5 | 101 | 111 |
6 | 110 | 101 |
7 | 111 | 100 |
Steps to convert binary code to Gray code:
E.g.: 11010
in Gray will be:
B: G
1: 1 (MSB)
1: 0 (1-1)
0: 1 (1-0)
1: 1 (0-1)
0: 1 (1-0)
Gray: 10111
Steps to convert Gray code to binary code:
E.g.: Gray code: 10111
in binary will be:
G: B
1: 1 (MSB)
0: 1 (1-0)
1: 0 (1-1)
1: 1 (0-1)
1: 0 (1-1)
Binary: 11010
Perform the following operations using BCD:
735 - 42
105 + 24 + 415
204 - 614
Convert the following from gray code to binary code:
10001
11101
01010
Convert the following from decimal to gray code:
104
211