Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

Binary Arithmetic Operations – Playing with the numbers DE Part 2

By Hai Prasaath K

In the previous tutorial, it was discussed that how any information can be represented by numbers and a set of numbers (code systems)can be used to store and manipulate information. A lot of real-world information is mathematical in nature like count of things, measurements of quantities etc. Such information may further have mathematical relationships. In order for a computer (digital circuit) to perform computing (mathematical operations) on such information, it must be first able to perform arithmetic operations. The arithmetic operations are the basic mathematical operations. Only by performing arithmetic operations, other algebraic operations can be performed on numerical data.

The digital circuits only understands and manipulate binary numbers. So, the arithmetic operations can be performed on data only in binary form. The digital circuits implement various arithmetic operations (binary arithmetic) with the help of logic gates. The electronic circuit of a binary adder (built by logic gates) with suitable shift registers can perform all arithmetic operations. Before understanding how digital circuits capable of performing mathematical operations can be built using logic gates, it is important to understand how various arithmetic operations are executed in binary form. So, let us learn the basics of Boolean algebra.

Binary Arithmetic Operations

Fig. 1: Binary Arithmetic Operations

Any binary number consists of 0 and 1. A binary number is formed by placement of 0 and 1 at different positional weights in the number. The arithmetic operations like addition, subtraction, multiplication and division of binary numbers follow the rules as summarized in the table below –


Binary Addition

The addition of two binary numbers is done the same way as is done for the decimal numbers. The addition is carried out from the least significant bits and it proceeds to higher significant bits, adding the carry resulting from the previous addition each time. For example, the addition of the binary numbers (1010)2 and (1111)2 is done the following manner –

1) The least significant bits are added, i.e. 0 + 1 = 1 with a carry 0.The addition carried out above involves the following steps –

2) The carry in the previous step is added to the next higher significant bits, i.e. 1 + 1 + 0 = 0 with a carry 1.

3) The carry in the above step is added to the next higher significant bits, i.e. 0 + 1 + 1 = 0 with a carry 1.

4) The preceding carry is added to the most significant bits, i.e. 1 + 1 + 1 = 1 with a carry 1.

So, the sum is (11001)2. The addition is also shown in the decimal number system in order to compare the results. It can be seen that whether numbers are added in decimal form or binary form, the end result is always equivalent. 

 

Binary Subtraction  

Like the subtraction of decimal numbers is done, similarly is the subtraction of binary numbers done. The subtraction is carried out from the least significant bits and proceeds to the higher significant bits. For example consider subtracting (1101)2 by (1001)2 as follow –


 
The subtraction carried out above involves the following steps –

1) The LSB in the first column are 1 and 1. Hence, the difference 1 – 1 = 0.

2) In the second column, the subtraction is performed as 0 – 0 = 0.

3) In the third column, the difference is given by 1 – 0 = 1.

4) In the fourth column (MSB), the difference is given by 1 – 1 = 0.

So, the difference between the two binary numbers is (0100)2.

When 1 is subtracted from 0, the 1 is borrowed from the immediate higher significant bit. The binary subtraction with borrow case is shown below –

 
The subtraction with borrow case carried out above involves the following steps –

1) The least significant bits in the first column are 1 and 1. Hence, the difference is 1 – 1 = 0.

2) In the second column, it is not possible to subtract the 1 from 0. So, a 1 has to be borrowed from the next MSB (3rd bit). Bit since the 3rd bit is also 0, borrowing has to be done from the MSB (4th bit). The borrowing of 1 from the 4th bit results in 1 and 10 with weight 4 in the 3rd column and 0 in 4th column as shown above. Now, the subtraction is performed as 10 – 1 = 1.

3) In the third column, the difference is given by 1 – 1 = 0.

4) In the fourth column (MSB), the difference is given by 0 – 0 = 0.

1’s and 2’s Complements –  The subtraction of a number from another can be accomplished by adding the complement of the subtrahend to the minuend. The exact difference can be obtained with minor manipulations.

1’s Complement Subtraction

The Subtraction of binary numbers using the 1’s complement method allows subtraction only by addition. The 1’s complement of a binary number can be obtained by changing all 1s to 0s and all 0s to 1s. The subtraction of a smaller number from a larger number by the 1’s complement method is done as follow –

1) Determine the 1’s complement of the smaller number.

2) Add this to the larger number.

3) Remove the carry and add it to the result. This carry is called end-around-carry.

For example, the subtraction of (1010)2 from (1111)2 using one’s compliment can be done as follow –

1) Determine the 1’s complement of the larger number.The subtraction of a larger number from a smaller one by the 1’s complement method involves the following steps –

2) Add this to the smaller number.

3) The answer is the 1’s complement of the true result and it is opposite in sign. There is no carry. The difference is a negative number. For example, the subtraction of (1111)2 from (1010)2 using one’s compliment can be done as follow –

2’s Complement Subtraction 

The 2’s complement of a binary number can be obtained by adding 1 to its 1’s complement. Subtraction of a smaller number from a larger one by the 2’s complement method involves following steps –

1) Determine the 2’s complement of the smaller number.

2) Add this to the larger number.

3) Omit the Carry.

The subtraction of a larger number from a smaller one by the 2’s complement method involves the following steps –

1) For subtracting the smaller number from larger number first take 1’s complement of smaller number.

2) Add 1 to the smaller number which has taken 1’s complement in above step to get 2’s complement.

3) Add the 2’s complement number determined in above step to the larger number given.

4) Discard the carry, the difference is the result obtained with negative sign.

For example, the subtraction of (1010)2 from (1111)2 using the 2’s complement is done the following way –

Binary Multiplication

The binary multiplication is as simple as decimal multiplication. The procedure is same as that of decimal multiplication. For example, the multiplication of (1011)2 and (1101)2 can be done as follow –

                        

The multiplication carried out above involves the following steps –

1) The least significant bit of the multiplier is taken. If the multiplier bit is 1, the multiplicand is copied as such and, if the multiplier bit is 0, a 0 is placed in all the bit positions.

2) The next higher significant bit of the multiplier is taken and the partial product is written with a shift to the left, as in step 1.

3) Step 2 is repeated for all other higher significant bits and each time a left shift is given.

4) When all the bits in the multiplier have been taken into account, the partial product terms are added, which give the actual product of the multiplier and the multiplicant.

 

Binary Division

The binary division is done similar to the decimal division. For example, the division of (1011)2 by (11)2 can be done as follow –

  Q=11 

11 |1011| R = 10

          11

          101

             11

             10

The division carried out above involves the following steps –

1) The MSB of the dividend is subtracted from the divisor. If there is need to borrow, MSB is used to borrow 1. The difference is written down and LSB next to it is carried down. The divisor as 1 or 0 is written from left to right in the quotient.

2) The step 1 is repeated until a remainder less than the divisor is left.

3) The quotient is noted from left to right which is the result of the division.

This is how the arithmetic operations of addition, subtraction, multiplication and division can be done on the binary numbers. In the next tutorial, learn about logical operations on binary numbers. The logical gates which form the digital circuits, perform the logical operations. The arithmetic operations are also realized on digital circuits with the help of logical operations only with the help of logic gates and their interconnections on the data paths. 


Filed Under: Recent Articles

 

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Introduction to Brain Waves & its Types (Part 1/13)
  • Understanding NeuroSky EEG Chip in Detail (Part 2/13)
  • Performing Experiments with Brainwaves (Part 3/13)
  • Amplification of EEG Signal and Interfacing with Arduino (Part 4/13)
  • Controlling Led brightness using Meditation and attention level (Part 5/13)
  • Control Motor’s Speed using Meditation and Attention Level of Brain (Part 6/13)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • EdgeLock A5000 Secure Authenticator
  • How to interface a DS18B20 temperature sensor with MicroPython’s Onewire driver
  • Introduction to Brain Waves & its Types (Part 1/13)
  • An Embedded Developer’s Perspective on IOT (Internet of Things)
  • Understanding NeuroSky EEG Chip in Detail (Part 2/13)

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Pic 16f877A Hex file
  • Need help to choose accelerometer
  • 7 segment display connections
  • finding attenuation coefficient in CST
  • Effect of variable gain amplifier and LNA on the input RF signal's phase

RSS Electro-Tech-Online.com Discussions

  • NOR gate oscillator in LTspice not working
  • How to designing a battery charging indicator circuit for 18650 battery pack
  • ICM7555 IC duty cycle limit at high frequency?
  • I've DESTROYED 3 piezo buttons :((((
  • led doorbell switch
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering