View Course Path

Binary Arithmetic – All rules and operations

Binary digital data is stored in almost every electronic circuitry. Whether it be microprocessors, flip flops, counters, or any concept in digital electronics – the binary number system is extensively used. But can we perform more actions on the binary numbers, apart from the Boolean operations? Is there a possibility to implement the basic mathematical operations such as addition, subtraction, multiplication or even division? Yep! Let’s take at all the operations that can be performed on binary numbers in this post, aptly titled as binary arithmetic.

Bit grouping – Various types of binary numbers

Let’s understand some terminologies first. Bits are grouped in various quantities. Let us see the different forms of Bit Grouping.

  • Bit: A single, bivalent unit of binary notation
  • Crumb, Tydbit, or Tayste: Equals to two bits.
  • Nybble or Nibble: Equals to four bits.
  • Nickle: Equals to five bits.
  • Byte: Equals to eight bits.
  • Deckle: Twice of a Nickle; equals to ten bits.
  • Playte: Equals to sixteen bits.
  • Dynner: Equals to thirty-two bits.
  • Word: This is entirely dependent on the computer system.
    • If a system uses 16 bit as the width of the ‘data path’, then the word for the respective system is of 16 bits. If instead, the system uses 32 bits grouping, then the word length equals to 32 bits.
    • Thus, a system implements n-bits as a standard for grouping bits; the word length for the system is n-bits.

Sign representation of Binary Numbers

We have positive and negative numbers in the real number system. Similarly, the same logic is also applied in the binary number system as well! We use the Sign-Magnitude Form to represent signed numbers. The corresponding number, after sign representation, has both the sign bit as well as the magnitude of the entire number. We shall go through this in detail.

Sign-Magnitude Form

  • If we have an n-bit binary number, one of the bits is the sign bit. The remaining (n-1) bits in the binary number represent the magnitude.
  • This sign bit represents whether the binary number is positive or negative.
  • The binary number system has only two values – 0 and 1.
  • Thus, we signify the positive/negative sign using these two digits itself.
  • If the sign bit’s value is 0, then the given binary number is a positive one.
  • Alternatively, if the sign bit’s value is a 1, the given binary number is a negative number. Usually, the sign bit is always the left most bit, which is the Most Significant Bit (MSB).

However, there is one ambiguity case.

When we consider the binary number 0, its magnitude always remains 0 itself. But we can represent it in a positive manner as well as a negative way (+0 and -0). This is shown as 00 and 10. This shows a little ambiguity as 0 is now depicted in two ways. The Sign-Magnitude form has a wide range, extending from – 2n-1 to 2n-1.

Consider a system having the word length is 8 bits (i.e. a byte). We shall represent the number 44 in its signed representation. We can write 44 in binary as (101100)2.

We represent the positive signed binary number of the real number 44, as shown below.

Signed Representation of +44
Signed Representation of +44

We represent the negative signed binary number of the real number -44, as shown below.

Signed Representation of -44
Signed Representation of -44

Binary addition

An important rule to be kept in mind is that just like real numbers, binary arithmetic calculations begin from the right side. For addition, we have four simple rules to remember:

  • 0 + 0 = 0 ,
  • 0 + 1 = 1 ,
  • 1 + 0 = 1 , and
  • 1 + 1 = 0 (with a carry to the adjacent left bit)

A + B

Sum

Carry

0 + 0 0 0
0 + 1 1 0
1 + 0 1 0
1 + 1 0 1

The first three cases are pretty self – explanatory. When we perform the addition 1+1, we get the value 2. But in the Binary World, 2 is represented as 102. Thus, we write a 0, and the 1 is overflown to the next bit.

Let us see an example of binary addition.

Binary Addition Example
Binary Addition Example

This example of binary arithmetic demonstrates the operation of binary addition. The carry overflow is shown above the operands.

Binary Subtraction

The binary subtraction has two new terms involved – the difference and the borrow. We have four main rules to remember for the binary Subtraction:

  • 0 – 0 = 0 ,
  • 0 – 1 = 1 , borrow/take 1 from the adjacent bit to the left
  • 1 – 0 = 1 , and
  • 1 – 1 = 0

In the second case, we see that 0 – 1 creates an ambiguity. We consider this as a borrow case and borrow 1 from the immediate left bit. Thus, this becomes 10 (binary 2). Thus, 2-1 gives 1.

A – B Difference Borrow
0 – 0 0 0
0 – 1 1 1
1 – 0 1 0
1 – 1 0 0

Let us see an example of binary subtraction.

Binary Subtraction Example
Binary Subtraction Example

This operation is a little bit tricky. Thus, we need to be careful while performing the calculations.

Binary Multiplication

The binary multiplication is the easiest one when compared to the other operations! It is pretty similar to decimal multiplication – any number multiplied with a 0 gives 0 as the product. Let us consider the four rules under this operation :

  • 0 x 0 = 0 ,
  • 0 x 1 = 0 ,
  • 1 x 0 = 0, and
  • 1 x 1 = 1
A x B Product
0 x 0 0
0 x 1 0
1 x 0 0
1 x 1 1
Binary Multiplication Example
Binary Multiplication Example

Binary Division

Under binary division, we perform two main functions – multiplication and subtraction. We also call this method as the long division method. Let us see an example of this.  We will perform a binary division of 11010 with 101.

Binary Division Example
Binary Division Example

In the given example, the quotient is 101, and the remainder is 1.

1’s complement

1’s complement might be the easiest, most fun thing to do in binary arithmetic. Though it sounds a little too arithmetic-ish, there is nothing much to do! Just two simple instructions to be followed, and you will have your 1’s Complemented Number! Given a binary number, just follow these two simple steps :

Step 1: In the number, toggle all the pre-existing 0s present to 1s.

Step 2: Now toggle all the pre-existing 1s present to 0s.

That’s it! These two steps can be performed done in any order.

Let us see these two steps. Consider the binary number 11001.

1's Complement Example
1’s Complement Example

Thus, 00110 is the 1’s complement of 11001. Similarly, if we need to find the 1’s complement of 1001, it is 0110!

Just complement the digits present in the binary number and voila! You have the 1’s complement of the number!

2’s complement

We have seen 1’s complement. What makes 2’s complement different?

In 2’s complement, we have two stages broken down three simple steps. You are already acquainted with two of the steps! Consider a binary number. We shall now see the three steps performing 2’s complement.

Step 1: In the number, toggle all the pre-existing 0s present to 1s.

Step 2: Now toggle all the pre-existing 1s present to 0s.

We have already done this in 1’s complement. Thus, the first stage of 2’s complement is to perform 1’s complement operation.  To complete the 2’s complement operation,

Step 3: Add binary 1 to the result of 1’s complement.

That gives you your final answer for 2’s compliment! Let us find the 2’s complement of 01110.

Stage 1: Find the One’s Complement of the number 01110.

2's Complement of 01110- Stage 1
2’s Complement of 01110- Stage 1

Stage 2: Add 1 to the result of the first stage, i.e. after the 1’s complement.

2's Complement of 01110 - Stage 2
2’s Complement of 01110 – Stage 2

Thus, 2’s complement of the binary number 01110 is 10010.

Bit Overflow

We say water has overflown from a container when its more than the capacity of the container. Similarly, a bit overflow also has a similar concept. Basically, a bit overflow happens when it exceeds the capacity of a system. This usually occurs in the 2’s complement operations. If we perform 2’s complement on 2 N-bit numbers and add them, the answer sometimes exceeds the N-bit capacity, thus having an overflowing bit.

Let us see an example of this. Let us add the 2’s complement of 7 (111)2 and 1 (001)2. The system capacity is of 3 –bits.

2’s complement of 7

2's Complement of 7
2’s Complement of 7

2’s Complement of 1

2's Complement of 1
2’s Complement of 1

The result of the 2’s complement of both 7 and 1 have 3-bits each. Let us now see the addition of the 2’s Complement of 1 and 7.

Addition of 2's Complement of 1 and 7
Addition of 2’s Complement of 1 and 7

The sum is a 4-bit number, thus presenting a case of overflow. This might create a problem in the functioning of circuitry and programs. In fact, in digital signal processing, it creates unnecessary oscillations in the design of digital filters. Thus we must address this by using fields large enough to handle the overflow bits.

This basic tutorial on binary arithmetic is more than sufficient for the remainder of this digital electronics course. If you have any queries or any ambiguous cases, let us know in the comments. We will do our best to resolve your doubts!

One thought on “Binary Arithmetic – All rules and operations

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.