Computers understand the language of binary. And for all arithmetic operations, algorithms are designed to do arithmetic operations in a binary framework. For all conventional binary arithmetic operations, such as addition, subtraction, multiplication, and division, binary numbers are organized in the form of truth tables. These truth tables form the fundamental basis for all the binary operations. Logic circuits are designed and implemented based on the truth tables. These logic gate circuits like AND gate, OR gate, etc. when implemented with these truth tables, act as digital circuits for all binary operations. In this article, we will look into how the binary numbers are framed into truth tables, for basic arithmetic operations.
What is Binary Arithmetic?
Binary arithmetic can be defined as a set of rules framed as truth tables for performing arithmetic operations. These operations are performed for the numbers represented in binary form. For each binary operation, truth tables are defined based on which the operations are performed. These operations conduct basic calculations like additions, subtraction, multiplication, and division. Before moving to binary basics, let’s quickly revise the binary form representation of decimal numbers.
Binary Equivalent of Decimal Numbers
The binary equivalent of decimal numbers is tabulated below.
For the above representation, four variable representations have been used for decimal numbers with a base of two. With four variables, we can represent numbers from 0 to 15. For evaluating the binary equivalent, the powers of two are considered. To check for the decimal equivalent, we can multiply the individual bit, with the powers of two. Consider the following example.
For the above example, the decimal equivalent of 1010 has been evaluated. For this, we need to multiply each bit with the powers of two. In the binary number, 1010, the rightmost bit is called the least significant bit (LSB) and the leftmost bit is called the most significant bit (MSB). So beginning from the least significant bit, it is multiplied with two to the power zero, then two to the power one, and so on.
Finally, all the values are added to get the decimal equivalent. So the decimal equivalent of 1010 is obtained as 10 (ten), as shown in the figure above. Similarly, we can find the decimal equivalent of all the binary bits. As mentioned before, with four variables, we can represent from 0-15, with six variables zero to 65, and so on.
Binary Arithmetic Basics
The binary arithmetic basics include binary addition, binary subtraction, binary multiplication, and binary division. Before moving into the binary operations, it is important to note that, only two variables 0 and 1 are used to represent binary numbers. Zero is considered to be low and one is considered to be high. The digital output consists of either low or high. Now lets the see the operations in detail.
Binary Arithmetic Addition
Binary addition includes adding two binary numbers. The truth table for binary addition is tabulated below.
As shown, while adding two low bits, the output is always low. This means when two zeros are added, it results in zero. There is no increment in overall value. Similarly, when a low bit is added to a high bit, the output is high. This means when zero is added to one, or one is added to zero, the sum is always 1. It can be also noted that there is no carry in the first three cases. For the last case, i.e, when the high bit is added with high, the output is high, with carrying. This means that, when one is added with one, the sum is 0 with carrying one.
The rules for the binary addition can be given as
- The addition is always started with the rightmost side or LSB bit.
- For the first step, when a low bit is added with low, output is low. There is no increment in the overall value of the number
- When a high bit is added with a low, or a low bit added with a high, output is always high. The overall value is incremented with one.
- When a high bit is added with high, output is high, with a carry. The value is incremented by one.
Let’s see an example for this case. See the following table
In this case, as mentioned, always begin from LSB. So first zero is added with zero, the output is zero with no carry. Then for the next step, one is added with one. In this case, the sum is zero as shown in the truth table, but carry is one, which goes to the next step. Again we have zero adding to zero, with carrying from the previous step.
So the sum is one, with no carry. And lastly, we have one added to zero, which gives the sum as one. We can also cross-check our answers. Here (1010) is added with (0010), whose decimal equivalent are 10 and 2, which gives the solution 12. And the decimal equivalent of 12 is 1100 as seen from the table. Hence our calculation is correct. Before moving into the next binary operation, we let’s see the concept of one’s and two’s complement.
For ease in calculation, a binary number is also represented in one’s complement form. This complement is used to represent the negative numbers. To represent the number in binary form, we need to complement each bit. Check the following example.
In the above example, to calculate the binary equivalent of a negative number such as -1, we use the one’s complement method. So to represent that, first the number -1 is converted to binary form. The binary equivalent of 1 is 0001. And then to represent the one’s complement of -1, in the binary equivalent, each bit is complemented.
This means, one is represented as 0 and 0 is represented as 1. Hence, 0001 becomes 1110, which is the binary representation of -1. The one’s complement is used in binary operations such as addition, subtraction, and division and is very helpful in dealing with negative number binary arithmetic operations.
The binary representation of negative numbers can also be done using two’s complement. In the two’s complement method, after obtaining the one’s complement, we add one to the least significant bit to obtain the two’s complement. Consider the following.
In this example, the two’s complement of the negative number -7 is evaluated. So the steps are
- First, calculate the binary representation of the given number
- Then find one’s complemented of the binary representation
- Then add one to the least significant bit to obtain the two’s complement.
The binary representation of 7 is 0111. One’ complement of 0111 is 1000. And then finally to obtain, two’s complement, add one to the least significant bit, and we obtain 1001 as the two’s complement representation of -7. The two’s complement is used in binary arithmetic operations such as addition, subtraction, multiplication, and division. Now we will see the next binary operation.
Binary Arithmetic Subtraction
The truth table for binary subtraction is given below.
In binary subtraction, we have two outputs, i.e., difference and borrow. When a low bit is subtracted from low, the output is low. There is no change in the overall value. When a high bit is subtracted from a low it is not possible. In this case, we need a borrow, to make the low bit as high.
So the output, in this case, is both the difference and borrow are high. This is the same as conventional subtraction we do in normal cases. For the next case, when the low bit is subtracted from the high, output is high. This means that the difference is one, with no borrow. And for the last case, when a high is subtracted from high, the difference is low. Except for the second case, for all cases, the borrow is zero. Let’s consider an example. Consider the following table.
For the example, we are subtracting, 1110 and 0011. As we did in addition, for this case also we must begin from the least significant bit. So the bits are 0 and 1. As mentioned, it is not possible to subtract a low from a high. So we need to take a borrow. The difference then becomes one. Next again we have two ones.
So one is subtracted from one, the difference is zero, and again the difference is subtracted from one, and the difference is one, with borrow. For the third step, we have borrowed one and bits as one and zero. So obviously the difference is zero with no borrow. For the last case, we have one subtracted from zero, the difference is one with no borrow.
The solution can be cross-checked also. The decimal equivalent of 1110 is 14, and the decimal equivalent of 0011 is 2. So the difference must be 12. Now check the result. It is 1011, whose binary equivalent is 12. Which means our subtraction is correct. Now we will see the next binary operation.
Binary Arithmetic Multiplication
The truth table for binary multiplication is given as follows
The rules for binary multiplication are quite simple. When both the input is low are, the output is low. And when one input is low, the other one being high, the output is low. The output is high only when both the inputs are high. An example of binary multiplication is given below.
In the above example, 100 (decimal equivalent 4) is multiplied with 011 (decimal equivalent 3) which gives the result 1100( decimal equivalent 12). Binary multiplication involves both binary addition and binary multiplication. It is the same as we do in conventional decimal multiplication.
The truth table for binary division is given below.
Binary division, has only two cases, as any number cannot be divided with 0, and zero by zero is not defined. So we have only two cases as shown. When low is divided with high, the output is low, and high is divided with high, the output is high. An example showing binary division is shown below.
In this example 101010 (decimal equivalent 42) is divided with 110 (decimal equivalent 6), giving a result of 111(decimal equivalent of 7) with the remainder being zero.
Know more about Binary Division Question & Answers.
Hence, we have seen, the four basic binary arithmetic operations, along with truth tables and solved examples. All the binary arithmetic operations can be implemented using logic gates. Logic gates like AND, OR, Ex-OR gates are used to implement the circuits. A simple example is the 4-bit adder circuit which uses 4 bits to add.