0% found this document useful (0 votes)
32 views34 pages

CO Unit 1-1

Uploaded by

Big Bro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views34 pages

CO Unit 1-1

Uploaded by

Big Bro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 34

UNIT – 1

Components of Computer : Processor, Memory, input – output unit, difference between organization
and architecture, hardware software interaction,
Number system : concept of bit and byte, types and conversion,
Complement's : 1's complement, 2's complement,
Binary arithmetic : Addition, Overflow, Subtraction.

Computer: A computer is a combination of hardware and software resources which integrate together
and provides various functionalities to the user. Hardware are the physical components of a computer
like the processor, memory devices, monitor, keyboard etc. while software is the set of programs or
instructions that are required by the hardware resources to function properly.
There are a few basic components that aids the working-cycle of a computer i.e. the Input- Process-
Output Cycle and these are called as the functional components of a computer. It needs certain input,
processes that input and produces the desired output. The input unit takes the input, the central
processing unit does the processing of data and the output unit produces the output. The memory unit
holds the data and instructions during the processing.

Digital Computer: A digital computer can be defined as a programmable machine which reads the
binary data passed as instructions, processes this binary data, and displays a calculated digital output.
Therefore, Digital computers are those that work on the digital data.

Details of Functional Components of a Digital Computer


A processor or processing unit is a digital circuit which performs operations on some external data
source, usually memory or some other data stream.
Processor is popualrly referred to as the " BRAIN" of the computer , is responsible for processing the
data inside the computer system.
It is also responsible for controlling all other components of the system.
The main operations of CPU include four phases –
1) Fetching instructions from the memory.
2) Decoding the instructions to decide what operations to be performed.
3) Executing the instructions.
4) Storing the results back in the memory.
This four phase process is known as the CPU cycle.

Parts Of Processor :
 Input Unit :The input unit consists of input devices that are attached to the computer. These
devices take input and convert it into binary language that the computer understands. Some of
the common input devices are keyboard, mouse, joystick, scanner etc.
 Central Processing Unit (CPU) : Once the information is entered into the computer by the
input device, the processor processes it. The CPU is called the brain of the computer because it is
the control center of the computer. It first fetches instructions from memory and then interprets
them so as to know what is to be done. If required, data is fetched from memory or input device.
Thereafter CPU executes or performs the required computation and then either stores the output
or displays on the output device. The CPU has three main components which are responsible for
different functions – Arithmetic Logic Unit (ALU), Control Unit (CU) and Memory registers
 Arithmetic Unit : The arithmetic unit, as its name suggests performs mathematical
calculations on data. Arithmetic calculations include addition, subtraction, multiplication
and division.
 Logic Unit : Logic unit is a part of CPU that performs logical operations on the data.
Logical decisions involve comparison of two data items to see which one is larger or
smaller or equal. It performs 16 different types of logical operations, which include
greater than (>), less than (<), equal to (=), not equal to (!=), shift left, shift right etc.
 Control Unit : The Control unit coordinates and controls the data flow in and out of CPU
and also controls all the operations of ALU, memory registers and also input/output units.
It is also responsible for carrying out all the instructions stored in the program. It decodes
the fetched instruction, interprets it and sends control signals to input/output devices until
the required operation is done properly by ALU and memory.
 Memory Registers : A register is a temporary unit of memory in the CPU. These are
used to store the data which is directly used by the processor. Registers can be of
different sizes(16 bit, 32 bit, 64 bit and so on) and each register inside the CPU has a
specific function like storing data, storing an instruction, storing address of a location in
memory etc. The user registers can be used by an assembly language programmer for
storing operands, intermediate results etc. Memory Data Register (MDR) is used for
storing operands and data. Accumulator (ACC) is the main register in the ALU and
contains one of the operands of an operation to be performed in the ALU.
 Memory : Memory attached to the CPU is used for storage of data and instructions and is called
internal memory The internal memory is divided into many storage locations, each of which can
store data or instructions. Each memory location is of the same size and has an address. With the
help of the address, the computer can read any memory location easily without having to search
the entire memory. when a program is executed, it’s data is copied to the internal memory and is
stored in the memory till the end of the execution. The internal memory is also called the
Primary memory or Main memory. This memory is also called as RAM, i.e. Random Access
Memory. The time of access of data is independent of its location in memory, therefore this
memory is also called Random Access memory (RAM). Read this for different types of RAMs
 Output Unit : The output unit consists of output devices that are attached with the computer. It
converts the binary data coming from CPU to human understandable form. The common output
devices are monitor, printer, plotter etc.

Memory :

Memory is the most essential element of a computing system because without it computer can’t perform
simple tasks. Both types of memory (RAM and ROM) are important for the computer, but they serve
different purposes. RAM is used to store data that the computer is currently using, while ROM is used to
store data that the computer needs to boot and operate. RAM is faster than ROM, as the data stored in it
can be accessed and modified in any order, while data stored in ROM can only be read.
Computer memory is of two basic types:
1. Primary memory (RAM and ROM)
2. Secondary memory (Hard Drive, CD, etc).
Primary Memory
Primary Memory is a type of Computer Memory which is directly accessed by the Preprocessor. It is
basically used to store data on which computer is currently working. It has lesser storage than Secondary
Memory. It is basically of two types:
1. Random Access Memory (RAM)
2. Read Only Memory (ROM)

Types of Primary Memory

Random Access Memory (RAM) is a type of computer memory that is used to temporarily store data
that the computer is currently using or processing. RAM is volatile memory, which means that the data
stored in it is lost when the power is turned off. RAM is typically used to store the operating system,
application programs, and data that the computer is currently using.
 It is also called read-write memory or the main memory or the primary memory.
 The programs and data that the CPU requires during the execution of a program are stored in this
memory.
 It is a volatile memory as the data is lost when the power is turned off.
Types of Random Access Memory (RAM)

 Static RAM (SRAM)


 Dynamic RAM (DRAM)

1. Static RAM: SRAM stands for Static Random Access Memory. It is a type of semiconductor which
is widely used in computing devices and microprocessors.
2. Dynamic RAM: DRAM stands for Dynamic Random Access Memory. It is made of Capacitors and
has smaller data life span than Static RAM.

Advantages of Random Access Memory (RAM)

 Speed: RAM is much faster than other types of storage, such as a hard drive or solid-state drive,
which means that the computer can access the data stored in RAM more quickly.
 Flexibility: RAM is volatile memory, which means that the data stored in it can be easily
modified or deleted. This makes it ideal for storing data that the computer is currently using or
processing.
 Capacity: The capacity of RAM can be easily upgraded, which allows the computer to store
more data in memory and thus improve performance.
 Power Management: RAM consumes less power compared to hard drives, and solid-state
drives, which makes it an ideal memory for portable devices.
Disadvantages of Random Access Memory (RAM)

 Volatility: RAM is volatile memory, which means that the data stored in it is lost when the
power is turned off. This can be a problem for important data that needs to be preserved, such as
unsaved work or files that have not been backed up.
 Capacity: The capacity of RAM is limited, and although it can be upgraded, it may still not be
sufficient for certain applications or tasks that require a lot of memory.
 Cost: RAM can be relatively expensive compared to other types of memory, such as hard drives
or solid-state drives, which can make upgrading the memory of a computer or device more
costly.

Read-Only Memory (ROM) –

Read Only Memory (ROM) is a type of computer memory that is used to permanently store data that
does not need to be modified. ROM is non-volatile memory, which means that the data stored in it is
retained even when the power is turned off. ROM is typically used to store the computer’s BIOS (basic
input/output system), which contains the instructions for booting the computer, as well as firmware for
other hardware devices.
 Stores crucial information essential to operate the system, like the program essential to boot the
computer.
 It is non-volatile.
 Always retains its data.
 Used in embedded systems or where the programming needs no change.
 Used in calculators and peripheral devices.
 ROM is further classified into four types- MROM, PROM, EPROM, and EEPROM.
Types of Read-Only Memory (ROM)
1. PROM (Programmable Read-Only Memory)
2. EPROM (Erasable Programmable Read Only Memory)
3. EEPROM (Electrically Erasable Programmable Read Only Memory)
4. MROM (Mask Read Only Memory)

1. PROM (Programmable read-only memory): It can be programmed by the user. Once programmed,
the data and instructions in it cannot be changed.
2. EPROM (Erasable Programmable read-only memory): It can be reprogrammed. To erase data
from it, expose it to ultraviolet light. To reprogram it, erase all the previous data.
3. EEPROM (Electrically erasable programmable read-only memory): The data can be erased by
applying an electric field, with no need for ultraviolet light. We can erase only portions of the chip.
4. MROM(Mask ROM): Mask ROM is a kind of read-only memory, that is masked off at the time of
production. Like other types of ROM, mask ROM cannot enable the user to change the data stored in it.
If it can, the process would be difficult or slow.

Advantages of Read Only Memory (ROM)

 Non-volatility: ROM is non-volatile memory, which means that the data stored in it is retained
even when the power is turned off. This makes it ideal for storing data that does not need to be
modified, such as the BIOS or firmware for other hardware devices.
 Reliability: Because the data stored in ROM is not easily modified, it is less prone to corruption
or errors than other types of memory.
 Power Management: ROM consumes less power compared to other types of memory, which
makes it an ideal memory for portable devices.

Disadvantages of Read Only Memory (ROM)

 Limited Flexibility: ROM is read-only memory, which means that the data stored in it cannot be
modified. This can be a problem for applications or firmware that need to be updated or
modified.
 Limited Capacity: The capacity of ROM is typically limited, and upgrading it can be difficult or
expensive.
 Cost: ROM can be relatively expensive compared to other types of memory, such as hard drives
or solid-state drives, which can make upgrading the memory of a computer or device more
costly.
Difference between RAM and ROM

Difference Random Access Memory (RAM) Read Only Memory (ROM)

ROM is a non-volatile memory that


RAM is a volatile memory that could
the could retain the
Data-Retention store the
data even when the power is turned
data as long as the power is supplied.
off.

Read/Write Read and write operations are supported. Only read operations are supported.

It is typically used to store firmware


Used to store the data that has to be or microcode, which is used
Use
currently processed by CPU temporarily. to initialize and control hardware
components of the computer.

Speed It is a high-speed memory. It is much slower than the RAM.

CPU CPU can easily access data stored in CPU cannot easily access data stored
Interaction RAM. in ROM.

Size and Large size with higher capacity, Small size with less capacity,
Capacity concerning ROM. concerning RAM.

Used as/in CPU Cache, Primary memory. Firmware, Micro-controllers.

The data stored is not as easily


Accessibility The data stored is easily accessible.
accessible as in the concerning RAM.

Cost RAM is more costlier than ROM. ROM is cheaper than RAM.

A RAM chip can store only a few A ROM chip can store multiple
Chip Size
gigabytes (GB) of data. megabytes (MB) of data.

Used for the temporary storage of data Used to store firmware, BIOS, and
Function
currently being processed by the CPU. other data that needs to be retained.
Secondary Memory
Secondary Memory is a type of Computer Memory which is used to permanently store the data and
Information. It has a larger data storage capacity than Primary Memory. Secondary Memory is not
directly accessible from CPU. It is basically of four types:
1. HardDisk
2. Compact Disc (CD)
3. Digital Versatile Disk (DVD)
4. Floppy Disk

Input and Output Unit:


An input/output device, often known as an IO device, is any hardware that allows a human operator or
other systems to interface with a computer. Input/output devices, as the name implies, are capable of
delivering data (output) to and receiving data from a computer (input). An input/output (I/O) device is a
piece of hardware that can take, output, or process data. It receives data as input and provides it to a
computer, as well as sends computer data to storage media as a storage output.

Input Devices

Input devices are the devices that are used to send signals to the computer for performing tasks. The
receiver at the end is the CPU (Central Processing Unit), which has work to send signals to the output
devices. Some of the classifications of Input devices are:
 Keyboard Devices
 Pointing Devices
 Mouse
 Track ball
 Touch screen
 Light pen
 Joystick
 Scanning devices
 Hand held scanner
 Flat bed scanner
 Drum scanner
 Optical Recognition devices
 OMR devices
 OCR devices
 MICR devices
 Bar code reader
 Digital camera
 Voice recognition system
 Media input devices
Output Devices

Output Devices are the devices that show us the result after giving the input to a computer system.
Output can be of many different forms like image, graphic audio, video, etc.
 Display Monitors
 CRT monitor
 LCD monitor
 TFT monitor
 LED monitor
 Printers
 Impact Printers
 Dot matrix
 Diasy Wheel
 Drum Printers
 Non impact printers
 Ink jet printers
 Laser printers
 Special purpose printers
 Plotters
 Drum Plotter
 Flat bed Plotter
 Ink jet Plotter
 Electrostatic Plotter
 Voice output systems
 Projectors

In computing, input/ output or I/O is the communication between an information processing system,
such as a computer, and the outside world, possibly a human or another information processing system.
Inputs are the signals or data received by the system and the outputs are the signals or data sent from it.
The term can also be used as part of an action to " perform I/O" is to perform an input or output
operation. I/O devices are the pieces of hardware used by a human( or other system) to communicate
with a computer. For instance, a keyboard or computer mouse is an input device for a computer, while
monitors and printers are output devices. Devices for communication between computers, such as
modem and network cards, typically perform both input and output operations.
The designation of a device as either input or output depends on perspective. Mouse and
keyboards take physical movements that the human user outputs and convert them into input signals that
a computer can understand; the output from these devices is the computer's input. Similarly printers and
monitors take signals that a computer outputs as input, and they convert these signals into a
representation that human user can understand. From the human user's perspective the process of
reading or being these representation is receiving output, this type of interaction between computers and
human is studied in the field dof human computer interaction.
In computer architecture, the combination of the CPU and main memory, to which the CPU can
read or write directly using individual instructions is considered the brain of a computer. Any transfer of
information to or from the CPU/ memory combo, for example by reading data from a disk drive, is
considered I/O. The CPU and its supporting circuitry may provide memory-mapped I/O that is used in
low – level computer programming, such as in the implementation of device drivers or may provide
access to I/O channels. An I/O algorithm is one designed to explicit locatlity and perform efficiently
when exchanging data with a secondary storage device, such as disk drive.

Difference between Organisation and Architecture :

What is Computer Architecture?

Computer Architecture is a blueprint for design and implementation of a computer system. It refers to
the overall design of a computer system, including the hardware and software components that make up
the system and how they interact with each other.
Computer architecture provides the functional details and behavior of a computer system. It involves
the design of the instruction set, the microarchitecture, and the memory hierarchy, as well as the design
of the hardware and software components that make up the system.
Computer Architecture mainly deals with the functional behavior of a computer system and covers the
"What to do?" part. It gives the functional description of requirements, design, and implementation of
the different parts of a computer system.
In the designing process of a computer system, the computer architecture is to be defined before the
computer organization.

What is Computer Organization?


Computer Organization refers to the way in which the hardware components of a computer system are
arranged and interconnected. It implements the provided computer architecture and covers the "How to
do?" part.
Computer Organization is to be defined after the decision of the computer architecture. It just provides
information that how operational attributes of a computer system are linked together and help in
realizing the architectural specification of the computer. It involves the design of the interconnections
between the various hardware components, as well as the design of the memory and I/O systems.
Differences between Computer Architecture and Computer Organization
The following table highlights how Computer Architecture is different from Computer Organization –

Key Computer Architecture Computer Organization

Computer architecture explains what a Computer organization explains


Purpose
computer should do. how a computer works.

Computer architecture provides Computer organization provides


Target functional behavior of computer structural relationships between
system. parts of computer system.

Computer architecture deals with high Computer organization deals with


Design
level design. low level design.

Computer architecture assists in Computer organization helps to


Role understanding the functionality of the understand the exact arrangement
computer. of component of a computer.
Actors in Computer architecture are Actor in computer organization is
Actors
hardware parts. performance.

Computer organization is started


Order Computer architecture is designed first. after finalizing computer
architecture.

Computer architecture involves the Computer organization involves


Involve relationship among logical attributes of the relationship among physical
s the system like instruction sets, data parts of the system like circuits,
types, addressing modes, etc. peripherals, etc.

Hardware and Software Interaction :

Although for using the computer one don’t really have to know how the hardware and software interact,
but for all these computer enthusiasts, this is surely interesting enough. It is a common fact that there are
a lot many differences between the hardware and software. But all these differences play their part in
building up the interaction between the hardware and software.

Software : The entire computer software can be broadly categorized into three parts : Device drivers,
operating system and application software. Simply all these types encompass the totality of the programs
present in your computer. Generally each and every program has its specific task to perform. For that
matter, the entire program is a set of instruction that are written to alter the state of hardware. Before
actually getting into how these instructions effect the hardware, here's something you need to understand
about computer hardware.

Hardware : The monitor, printer, hard drive, RAM, graphic card and all the other physical components
which are connected to the computer which can be physically touched, is the computer hardware.
Without hardware, software had no idea where to work on. Hence hardware and software run hand in
hand for implementing whatever the user wants.

The difference and the interaction between Hardware and Software :

There are a lot many differences between the hardware and software. Including the nature,
functionality and the ability to be changed again and again the software and hardware differ from each
other in numerous ways. But ultimately they are useless in the absence of the other. Once you perform
programming, using some high – level programming language (e.g. C or C#) the entire set of code you
write is converted into 1's and 0's. This is taken care of by the compiler which converts written code into
binary (1's and 0's) once the program follows a defined set of rules or the syntax. These 1's and 0's are
simply the voltage levels which establish the control over all the electric circuits.
For example, consider a simple LED bulb connected to a battery supply and a small switch.
Whenever this switch is closed the LED glows and once the switch is open the LED gets turned off. The
bulb glows and gets turned off because of the variation in voltage levels in these instances. When the
switch is closed the entire supply voltage is across the LED bulbs due to which it glows and once the
switch is open the bulb isn't supplied with the required voltage and hence it doesn't work. This is how
voltage levels control the LED bulb. The physical act of turning ON and OFF by opening and closing
the LED bulb can be substituted by any other mechanism. This works fine until this mechanism actually
is able to operate as per your requirement.
In case of computers, the entire hardware is supplied varying voltages due to which different
components get activated at the same or different time instances and achieve a particular task. Finally all
the binary data in a computer is nothing but the voltage level information, for which a particular task is
assigned to be executed.
The entire sequence of events that occur for hardware and software interaction is under the
control of Operating system. All the driver software help the Operating system to actually communicate
with the hardware, so as to execute the application software.

Number system :
The technique to represent and work with numbers is called number system. The number system is a
representation for a given number.

BIT : A bit is a binary digit, the smallest increment of data on a computer. A bit can hold only one of
two values: 0 or 1, corresponding to the electrical values of OFF or ON, respectively.
Because bits are so small, we rarely work with information one bit at a time. Bits are usually
assembled into a group of eight to form a byte.

The number system are of two types –


1)Non – positional number system
2)Positional number system.

Non – Positional number system –


Non-positional number system is also known as non-weighted number system. Digit value is
independent of its position. Non-positional number system is used for shift position encodes and error
detecting purpose.
Few examples of non-weighted number system are gray code, roman code, excess-3 code, etc.

Positional number system –


In positional number system, each symbol represents different, value depending on the position
they occupy in a number.
In positional number system, each system has a value that relates to the number directly next to
it. The total value of a positional number is the total of the resultant value of all position.
e.g. 12 can be 1*10 + 2*1 = 10 + 2 = 12

Types of positional number system –


Based on the base value and the number of allowed digits, number systems are of many types. The four
common types of Number System are:
 Binary Number System
 Octal Number System
 Decimal Number System
 Hexadecimal Number System

Binary Number System :


The binary number system uses only two digits: 0 and 1. The numbers in this system have a base of 2.
Digits 0 and 1 are called bits and 8 bits together make a byte. The data in computers is stored in terms of
bits and bytes. The binary number system does not deal with other numbers such as 2,3,4,5 and so on.
For example: 100012, 1111012, 10101012 are some examples of numbers in the binary number system.

Octal Number System

The octal number system uses eight digits: 0,1,2,3,4,5,6 and 7 with the base of 8. The advantage of this
system is that it has lesser digits when compared to several other systems, hence, there would be fewer
computational errors. Digits like 8 and 9 are not included in the octal number system. Just like the
binary, the octal number system is used in minicomputers but with digits from 0 to 7. For example, 35 8,
238, and 1418 are some examples of numbers in the octal number system.
Decimal Number System

The decimal number system uses ten digits: 0,1,2,3,4,5,6,7,8 and 9 with the base number as 10. The
decimal number system is the system that we generally use to represent numbers in real life. If any
number is represented without a base, it means that its base is 10. For example, 72310, 3210, and
425710 are some examples of numbers in the decimal number system.

Hexadecimal Number System

The hexadecimal number system uses sixteen digits/alphabets: 0,1,2,3,4,5,6,7,8,9 and A,B,C,D,E,F with
the base number as 16. Here, A-F of the hexadecimal system means the numbers 10-15 of the decimal
number system respectively. This system is used in computers to reduce the large-sized strings of the
binary system. For example, 7B316, 6F16, and 4B2A16 are some examples of numbers in the hexadecimal
number system.
Conversion of Number Systems

A number can be converted from one number system to another number system using number system
formulas. Like binary numbers can be converted to octal numbers and vice versa, octal numbers can be
converted to decimal numbers and vice versa, and so on. Let us see the steps required in converting
number systems.

Steps for Conversion of Binary to Decimal Number System


To convert a number from the binary to the decimal system, we use the following steps.
 Step 1: Multiply each digit of the given number, starting from the rightmost digit, with the
exponents of the base.
 Step 2: The exponents should start with 0 and increase by 1 every time we move from right to
left.
 Step 3: Simplify each of the above products and add them.
Let us understand the steps with the help of the following example in which we need to convert a
number from binary to decimal number system.

Example: Convert (100111)2 into the decimal system.


Solution:
Step 1: Identify the base of the given number. Here, the base of 1001112 is 2.
Step 2: Multiply each digit of the given number, starting from the rightmost digit, with the exponents of
the base. The exponents should start with 0 and increase by 1 every time as we move from right to left.
Since the base is 2 here, we multiply the digits of the given number by 20, 21, 22 , and so on from right to
left.
1 0 0 1 1 1

1 * 20
1 * 21
1 * 22
0 * 23
0 * 24
1 * 25

Step 3: We just simplify each of the above products and add them.
1 0 0 1 1 1

1 * 20 = 1 * 1 = 1
1 * 21 = 1 * 2 = 2
1 * 22 = 1 * 4 = 4
0 * 23 = 0 * 8 = 0
0 * 24 = 0 * 16 = 0
1 * 25 = 1 * 32 = 32
----------
SUM 39
Here, the sum is the equivalent number in the decimal number system of the given number. Or, we can
use the following steps to make this process simplified.
100111 = (1 × 25) + (0 × 24) + (0 × 23) + (1 × 22) + (1 × 21) + (1 × 20)
= (1 × 32) + (0 × 16) + (0 × 8) + (1 × 4) + (1 × 2) + (1 × 1)
= 32 + 0 + 0 + 4 + 2 + 1
= 39
Thus, (100111)2 = (39)10.

Example: Convert (110000100)2 into the octal system.


Solution:
Step 1: We convert binary to octal by grouping 3 bits from the right most side.

1 1 0 0 0 0 1 0 0 =

6 0 4
Step 2 : Now we combine all the read parts in octal number
Thus, (110000100)2 = (604)8.

Example: Convert (110000100)2 into the hexadecimal system.


Solution: 1st way
Step 1: We convert binary to hexadecimal by grouping 4 bits from the right most side.

1 1 0 0 0 0 1 0 0 =

1 8 4
Step 2 : Now we combine all the read parts in hexadecimal number.
Thus, (110000100)2 = (184)16.

Example: Convert 10101111002 to the hexadecimal system.


Solution: 2nd way
Step 1: Convert this number to the decimal number system as explained in the above process.

1 0 1 0 1 1 1 1 0 0

0 * 20 = 0 * 1 = 0
1
0*2 =0*2= 0
1 * 22 = 1 * 4 = 4
3
1*2 =1*8= 8
1 * 24 = 1 * 16 = 16
1 * 25 = 1 * 32 = 32
0 * 26 = 0 * 64 = 0
1 * 27 = 1 * 128=128
0 * 28 = 0 * 256= 0
1 * 29 = 1 * 512= 512
--------------
SUM - 700
Thus, (1010111100)2 = (700)10
Step 2: Convert the above number (which is in the decimal system), into the required number system
(hexadecimal).
Here, we have to convert 70010 into the hexadecimal system using the above-mentioned process. It
should be noted that in the hexadecimal system, the numbers 11 and 12 are written as B and C
respectively.
16 70
0 (which is C in hexadecimal)
16 43 12 (which is B in hexadecimal)
2 11

Thus, (700)10 = 2BC16


From the equations (1010111100)2 = (2BC)16

Conversion of Decimal Number System to Binary / Octal / Hexadecimal Number System


To convert a number from the decimal number system to a binary/octal/hexadecimal number system, we
use the following steps. The steps are shown on how to convert a number from the decimal system to the
octal system.
To convert a number from decimal system to binary/octal/ Hexadecimal number system, we use the
following steps.
 Step 1: Divide each digit of the given number, starting from the rightmost digit, with the
exponents of the base.
 Step 2: The exponents should start with 0 and increase by 1 every time we move from right to
left.
 Step 3: Simplify each of the above products and add them.

Example 1: Convert (300)10 into the binary number system with base 2.
Solution:
Step 1: Identify the base of the required number. Since we have to convert the given number into the
binary system, the base of the required number is 2.
Step 2: Divide the given number by the base of the required number and note down the quotient and the
remainder in the quotient-remainder form. Repeat this process (dividing the quotient again by the base)
until we get the quotient less than the base.

2 300
2 150 0
2 75 0
2 37 1
2 18 1
2 9 0
2 4 1
2 2 0
1 0

The equivalent number in the binary system is obtained by reading all the remainders and just the last
quotient from bottom to top as shown above.
Thus, (300)10 = (100101100)2

Example: Convert (4320)10 into the octal system.


Solution:
Step 1: Identify the base of the required number. Since we have to convert the given number into the
octal system, the base of the required number is 8.
Step 2: Divide the given number by the base of the required number and note down the quotient and the
remainder in the quotient-remainder form. Repeat this process (dividing the quotient again by the base)
until we get the quotient less than the base.
8 4320
8 540 0
8 67 4
8 8 3
1 0

Step 3: The given number in the octal number system is obtained just by reading all the remainders and
the last quotient from bottom to top.

Therefore, (4320)10 = (10340)8

Example: Convert (4285)10 into the hexadecimal system.


Solution:
Step 1: Identify the base of the required number. Since we have to convert the given number into the
hexadecimal system, the base of the required number is 16.
Step 2: Divide the given number by the base of the required number and note down the quotient and the
remainder in the quotient-remainder form. Repeat this process (dividing the quotient again by the base)
until we get the quotient less than the base.
16 428
5 (which is D in hexadecimal)
16 267 13 (which is B in hexadecimal)
16 16 11
1 0

Step 3: The given number in the hexadecimal number system is obtained just by reading all the
remainders and the last quotient from bottom to top.
Therefore, (4285)10 = (10BD)16

Example: Convert (144)8 into the decimal system.


Solution: The base of 1448 is 8. We will convert this number into the decimal system as follows:

1 4 4
4 * 80 = 4 * 1 = 4
4 * 81 = 4 * 8 = 32
4 * 82 = 4 * 64 = 64
----------
SUM = 100
Thus, (144)8 = (100)10
Example : Convert (5BC)16 into the decimal system.
Solution: 5BC16 is in the hexadecimal system. We know that B = 11 and C = 12 in the hexadecimal
system. So we get the equivalent number in the decimal system using the following process:

5 B C
= 5 11 12
12 * 160 = 12 * 1 = 12
1
11 * 16 = 12 * 16 = 176
5 * 162 = 12 * 256 = 1280
----------
SUM - 1468
Thus, (5BC)16 = (1468)10

Conversion of floating numbers into binary :

Example : 4.25
Where 4 is an integral part and 0.25 is a fractional part.
Step 1 : Integral part (4)
- To convert an integral part into binary, just follow the usual method .
2 4
2 2 0
1 0

Step 2 : Fractional part (0.25)


- to convert the fractional part to binary, multiply fractional part with 2 and take the one bit which
appears before the decimal point.
- Follow the same procedure with after the decimal point (.) part until it becomes 1.0
So, 0.25 * 2 = 0.50 // take 0 and move .50 to next
0.50 * 2 = 1.00 // take 1 and stop the process
Therefore 0.25 = (01)2
Step 3 : Combine both integral and fractional part (4.25)10 = (100.01)2

Example : 10.75
Integral part 10 = (1010)2
Fractional part (0.75)
0.75 * 2 = 1.50 // take 1 and move .50 to next step.
0.50 * 2 = 1.00 // take 1 and stop the process as there is no remainder.
Ans = (10.75)10 = (1010.11)2

Note : Some fractional part numbers will not end up with 1.0 with the above method. In floating storage,
the computer will allocate 23 bits for the fractional part. So its enough to do the above method at max 23
times.
Conversion of floating numbers into octal :

Example : 24.25
Where 24 is an integral part and 0.25 is a fractional part.
Step 1 : Integral part (24)
- To convert an integral part into octal, just follow the usual method .
8 2
4
3 0

Step 2 : Fractional part (0.25)


- to convert the fractional part to binary, multiply fractional part with 8 and take the one bit which
appears before the decimal point.
- Follow the same procedure with after the decimal point (.) part until it becomes 1.0
So, 0.25 * 8 = 2 // take 2 and stop the process as there is no remainder.
Therefore 0.25 = (2)8
Step 3 : Combine both integral and fractional part (24.25)10 = (30.2)8

Conversion of floating numbers into hexadecimal numbers :

Example : 20.00390625
Where 20 is an integral part and 0.00390625 is a fractional part.
Step 1 : Integral part (20)
- To convert an integral part into hexadecimal, just divide the number with 16 and write the remainder.
16 20
1 4

Step 2 : Fractional part (0.00390625)


- to convert the fractional part to hexadecimal, multiply fractional part with 16 and take the one bit
which appears before the decimal point.
- Follow the same procedure with after the decimal point (.) part until it becomes 1.0
So, 0.00390625 * 16 = 0.0625 // take 0 and move 0.0625 for next step.
.0625 * 16 = 1.000 // take 1 and stop the process.
Therefore 0.00390625 = (01)16
Step 3 : Combine both integral and fractional part (20.00390625)10 = (14.01)16

Convert binary fraction to Decimal:

Example : (110.101)2
Step 1 : Convert the integral part of binary to decimal
a) Multiply each digit separately from left side of radix point till the first digit by 2 0, 21, 22, …so
on respectively.
b) Add all the result coming from step 1.
c) Equivalent integral decimal number would be the result obtained in step 2.
1 1 0
0 * 20 = 0 * 1 = 0
1 * 21 = 1 * 2 = 2
1 * 22 = 1 * 4 = 4
--------
6
Step 2 : Convert the fractional part of binary to decimal equivalent.
a) Divide each digit from right side of radix point till the end by 2-1, 2-2,2-3 ,2-4 …so on
respectively.
b) Add all the result coming from step 1.
c) Equivalent fractional decimal number would be the result obtained in step 2.
.101 = (1 * ½1) + (0 * ½2) + (1 * ½3)
= 1*0.5 + 0 * 0.25 + 1*0.125
= 0.625
So equivalent decimal to binary fractional is - (110.101)2 = (6.625)10

Convert octal fraction to Decimal:

Example : (127.25)8
Step 1 : Convert the integral part of octal to decimal
a) Multiply each digit separately from left side of radix point till the first digit by 8 0, 81, 82, …so
on respectively.
b) Add all the result coming from step 1.
c) Equivalent integral decimal number would be the result obtained in step 2.

1 2 7
7 * 80 = 7 * 1 = 07
2 * 81 = 2 * 8 = 16
1 * 82 = 1 * 64 = 64
--------
77
Step 2 : Convert the fractional part of binary to decimal equivalent.
a) Divide each digit from right side of radix point till the end by 8-1, 8-2,8-3 ,8-4 …so on
respectively.
b) Add all the result coming from step 1.
c) Equivalent fractional decimal number would be the result obtained in step 2.
.25 = (2 * 1/81 ) + (5 * 1/82)
= 2 * 0.125 + 5 * 0.015625
= 0.25 + 0.078125 = .328125
So equivalent decimal to binary fractional is - (127.25)8 = (77.328125)10

Convert hexadecimal fraction to Decimal:

Example : (12F.01B)16
Step 1 : Convert the integral part of hexadecimal to decimal
a) Multiply each digit separately from left side of radix point till the first digit by 16 0, 161, 162, …
so on respectively.
b) Add all the result coming from step 1.
c) Equivalent integral decimal number would be the result obtained in step 2.

1 2 F
F * 160 = 15 * 1 = 15
2 * 161 = 2 * 16 = 32
1 * 162 = 1 * 256 = 256
--------
293
Step 2 : Convert the fractional part of hexadecimal to decimal equivalent.
a) Divide each digit from right side of radix point till the end by 16-1, 16-2,16-3 ,16-4 …so on
respectively.
b) Add all the result coming from step 1.
c) Equivalent fractional decimal number would be the result obtained in step 2.
.01B = (0 * 1/161 ) + (1 * 1/162) + (B * 1/163)
= 0 * 0.0625 + 1 * 0.00390625 + 11 * 0.000244140625
= 0 + 0.00390625 + .00268554688 = 0.00659179688
So equivalent decimal to hexadecimal fraction is - (12F.01B)16 = (293.00659179688)10

Convert floating point octal to hexadecimal

Example : (13.54)8
Step 1 : In the integer part of octal take each digit and convert it to 3 bit binary equivalent number from
right to left and then place them side by side.

1 3
011
001

(13)8 = (001011)2
Step 2 : For the octal fraction take each digit and convert it to 3 bit binary equivalent number from left
to right and then place them side by side .

.5 4
100
101

(.54)8 = (101100)2
Step 3 : Combine the integral part and fraction part of octal to binary representation –
(13.54)8 = (1011.1011)2
Step 4 : Now we convert integer part of binary to hexadecimal by grouping 4 bits from the right most
side.
(1011)2 = (11)10 which is B in hexadecimal.
Step 5 : For the binary fractional part again group 4 bits starting from left side and convert it to
hexadecimal.
(.1011)2 = (11)10 which is B in hexadecimal.

Step 6 : Combine both the parts of step 4 and 5.

(13.54)8 = (B.B)16

Complements :
Complements are used in digital computers for facilitating the subtraction operation and for logical
manipulation. There are two methods of complements for each base r system : the r's complement and
the (r-1)'s complement.

Diminshed Radix complement : ((r-1)'s complement)


If we are given a number N in base – r having n digits the (r-1)'s complement or Diminished
Radix complement is defined as – (rn – 1) – N. Thus we have to follow the steps as –
Steps to find (r-1)’s complement:
 Subtract each digit of the number from the largest number in the number system with base .
 For example, if the number is a three-digit number in base 9, then subtract the number from 888
as 8 is the largest number in base 9 number system.
 The obtained result is the (r-1)’s (8’s complement) complement.
Example :
Let us take r =10 i.e. we need to find 9's complement of a number. Let number be N, then 9's
complement of N is denoted as –
(10n – 1) – N i.e. 99…..9 (n digits) – N
Let us take N = 1988
Here r = 10 and n = 4
So 9's complement of 1988 is
9999 – 1988 = 8001
Example :
Let us take N = 01234, here r =10 and n=5, so 9's complement of 01234 is –
99999 – 01234 = 98765

For binary numbers, r = 2


So 2n is represented as 1000…..00 (1 followed by n 0's)
This implies 2n – 1 is represented as 111…111 ( n 1's)
In the case of binary 1's complement, we see that it has all 1's i.e. 1 – 1 = 0 and 1 – 0 = 1
This means if we just change 1 from 0 and 0 from 1, we directly get its complement.
Example :
Let us take N = 010010 and r =2 and n = 6. So directly 1's complement of N is
111111 – 010010 = 101101.

Radix complement (r's complement)


If we are given a number N in base – r having n digits the (r)'s complement or Radix complement
is defined as -
rn – N
This is also same as adding 1 to (r-1)'s complement to get r's complement.
Steps to find r’s complement: To find r’s complement, just add 1 to the calculated (r-1)’s complement.
Now, this holds true for any base in the number system that exists. It can be tested with familiar bases
that is the 1’s and 2’s complement.
Example :
Let N = 12345 and n = 5 and r = 10.
So 10's complement of N is –
100000 – 12345 = 98765
For binary number, r = 2
Let us take N = 010101, n = 6 and r = 2.
So 2's complement is 1's complement + 1 i.e. change 1 to 0 and 0 to 1 and then add 1 to the
number. So 2's complement of 010101 is –
101010 + 1 = 101011

We can also do the above as 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.

Binary arithmetic –
Binary is a base-2 number system that uses two states 0 and 1 to represent a number. We can also
call it to be a true state and a false state. A binary number is built the same way as we build a
normal decimal number. Binary arithmetic is an essential part of various digital systems. You can add,
subtract, multiply, and divide binary numbers using various methods. These operations are much easier
than decimal number arithmetic operations because the binary system has only two digits: 0 and 1.
Binary additions and subtractions are performed as same in decimal additions and subtractions.
When we perform binary additions, there will be two outputs: Sum (S) and Carry (C).

1. There are four rules for binary addition:

Inpu Input Sum (S) Carry


t B A+B (C)
A
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1

In fourth case, a binary addition is creating a sum of (1 + 1 = 10) i.e. 0 is written in the given column
and a carry of 1 over to the next column.
Example − Addition
0011010 + 001100
11 --- Carry
0011010 = 2610
+ 0001100 = 1210
----------------
0100110 = 3810
2. There are four rules for binary subtraction:

Inpu Input (S) Borrow


t B A-B (B)
A
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0

0011010 – 001100
11 --- Borrow
0011010 = 2610
+ 0001100 = 1210
----------------
0001110 = 1410

3. There are four rules for binary multiplication:

Input Input Multiply


A B A*B
0 0 0
0 1 0
1 0 0
1 1 1

Multiplication is always 0, whenever at least one input is 0.


0011010 * 001100
0011010 =2610
* 0011001 =1210
---------------
0000000
0000000X
0 0 1 1 0 1 0 XX
0 0 1 1 0 1 0 XXX
-------------------------
0 100111000 =31210

4. There are four parts in any division: Dividend, Divisor, quotient, and remainder.

Inpu Input Division


t B A/B
A
0 0 Not defined
0 1 0
1 0 Not defined
1 1 1

The result is always not defined, whenever the divisor is 0.

Overflow :
 When two numbers of n digits each are added and the sum occupies n+1 digits, we say that an
overflow occurred.
 When the addition is performed with paper and pencil, an overflow is not a problem since there
is no limit to the width of the page to write down the sum.
 An overflow is a problem in digital computers because the width of registers is finite.
 A result that contains n+1 bits cannot be accomodated in a register with a standard length of n
bits.
 When two unsigned numbers are added, an overflow is detected from the end carry out of the
most significant position.
 In case of signed numbers, the leftmost bit always represents the sign (0 -- +ve, 1 -- -ve) and
negative numbers are in 2's complements from when two signed numbers are added, the sign bit
is treated as part of the number and the end carry does not indicate an overflow.
 A 4 – bit number, for example, has range [0 … 15]. 4 – bit binary addition overflows if the result
exceeds 15. The fifth bit is discarded, producing an incorrect result in the remaining four bits.
Overflow can be detected by checking for a carry out of the most significant column.
 Example: Compute (1101)2 + (0101)2
1101
0101
10010
The result overflows the range of a 4 bit binary number. If it must be stored as 4 bits the most
significant bit is discarded, leaving the incorrect result of 0010. If the computation had been done using
number with five or more bits, the result (10010)2, would have been correct.
 An overflow cannot occur after an addition if one number is positive and other is negative.
 An overflow may occur if the two numbers added are both positive or negative.
Example: 1 1 11
+ 70 0 1 0 0 0 1 1 0 - 70 1 0 1 1 1 0 1 0
+ 80 0 1 0 1 0 0 0 0 - 80 1 0 1 1 0 0 0 0
---------------------------- ----------------------------
+150 1 0 0 1 0 1 1 0 -150 0 1 1 0 1 0 1 0
Note that the 8 bit result that should have been positive has a negative sign bit and that should
have been negative has a positive sign bit.
The answer can't be accomodated with 8 bits, we say that an overflow occurred.
 An overflow condition can be detected by observing the carry into the sign bit position and the
carry out of the sign bit position. If these two carries are not equal an overflow condition is
produced.

Signed and Unsigned Integer Representation:


The integer variables are represented in a signed and unsigned manner. The positive and negative
values are differentiated by using the sign flag in signed numbers. The unsigned numbers do not use any
flag for the sign, i.e., only positive numbers can be stored by the unsigned numbers.
1) Unsigned Representation:
Unsigned numbers don't have any sign, these can contain only magnitude of representation.
Since there is no sign bit in this represents its magnitude only. Zero (0) is also unsigned number. This
representation has only one zero (0), which is always positive.
Example: (92)10 – (1011100)2
It's 7 bit binary magnitude of the decimal no. 92
2) Signed Representation:
Signed numbers contain sign bit, this representation distinguishes positive and negative numbers.
This method contains both, sign bit and magnitude of a number.
 When a binary number is positive, the sign bit is represented by 0 and the magnitude by a
positive binary number. Eg. Consider the signed number 14 stored in an 8 bit register. +14 is
represented by a sign bit of 0 in the leftmost position followed by the binary value of 14.
Sign bit Magnitude
0 0001110
 When the number is negative, the sign bit is represented by 1 but the rest of the number may be
represented in one of three possible ways –
1. Signed magnitude representation –
In this representation a negative number consists of the magnitude and a negative sign.
Eg. Sign bit Magnitude
-14 1 0001110
-6 1 0000110
2. Signed 1's complement representation –
1's complement of a number is obtained by inverting each bit of given number. Replace
1's with 0's and 0's with 1's
Eg. Sign bit Magnitude
-14 1 0001110
14 0001110→1110001
3. Signed 2's complement representation –
2's complement of a number is obtained by inverting each bit of given number plus 1 to
least significant bit (LSB).
(14)10 → (0 0 0 1 1 1 0)2
1's complement → 1 1 1 0 0 0 1
+ 1
2's complement→ 1 1 1 0 0 1 0

Thus, we can represent -14 as Sign bit Magnitude


In signed Magnitude representation - 1 0001110
In signed 1's complement - 1 1110001
In signed 2's complement - 1 1110010

Binary Arithmetic using 1's and 2's complement:


1) Addition using 1's complement - There are three different cases possible when we add two binary
numbers which are as follows:

Case 1: Addition of the positive number with a negative number when the positive number has
a greater magnitude.
Initially, calculate the 1's complement of the given negative number. Sum up with the given
positive number. If we get the end-around carry 1, it gets added to the LSB.

Example: 1101 and -1001

Step 1 : First, find the 1's complement of the negative number 1001. So, for finding 1's
complement, change all 0 to 1 and all 1 to 0. The 1's complement of the number 1001 is 0110.
Step 2 : Now, add both the numbers, i.e., 1101 and 0110;
1101+0110=1 0011
Step 3 : By adding both numbers, we get the end-around carry 1. We add this end around carry
to the LSB of 0011.
0011+1=0100

Case 2: Adding a positive value with a negative value in case the negative number has a
higher magnitude.
Initially, calculate the 1's complement of the negative value. Sum it with a positive number. In this case,
we did not get the end-around carry. So, take the 1's complement of the result to get the final result.
Note: The resultant is a negative value.

Example: 1101 and -1110

Step 1: First find the 1's complement of the negative number 1110. So, for finding 1's
complement, we change all 0 to 1, and all 1 to 0. 1's complement of the number 1110 is 0001.
Step 2 : Now, add both the numbers, i.e., 1101 and 0001;
1101+0001= 1110
Step 3 : Now, find the 1's complement of the result 1110 that is the final result. So, the 1's
complement of the result 1110 is 0001, and we add a negative sign before the number so that we
can identify that it is a negative number.

Case 3: Addition of two negative numbers


In this case, first find the 1's complement of both the negative numbers, and then we add both these
complement numbers. In this case, we always get the end-around carry, which get added to the LSB, and
for getting the final result, we take the 1's complement of the result.
Note: The resultant is a negative value.

Example: -1101 and -1110 in five-bit register

Step 1 : Firstly find the 1's complement of the negative numbers 01101 and 01110. So, for
finding 1's complement, we change all 0 to 1, and all 1 to 0. 1's complement of the number
01110 is 10001, and 01101 is 10010.
Step 2 : Now, we add both the complement numbers, i.e., 10001 and 10010;
10001+10010= 1 00011
Step 3 : By adding both numbers, we get the end-around carry 1. We add this end-around carry
to the LSB of 00011.
00011+1=00100
Step 4 : Now, find the 1's complement of the result 00100 that is the final answer. So, the 1's
complement of the result 00100 is 110111, and add a negative sign before the number so that we
can identify that it is a negative number.

2) Subtraction using 1's complement - These are the following steps to subtract two binary numbers
using 1's complement
- In the first step, find the 1's complement of the subtrahend.
- Next, add the complement number with the minuend.
- If got a carry, add the carry to its LSB. Else take 1's complement of the result which will be
negative
Note: The subtrahend value always get subtracted from minuend.

Example 1: 10101 – 00111 (with carry)

We take 1's complement of subtrahend 00111, which comes out 11000. Now, sum them. So,
10101+11000 =1 01101.
In the above result, we get the carry bit 1, so add this to the LSB of a given result, i.e.,
01101+1=01110, which is the answer.

Example 2: 10101 – 10111 (without carry)

We take 1's complement of subtrahend 10111, which comes out 01000. Now, add both of the
numbers. So,
10101+01000 =11101.
In the above result, we didn't get the carry bit. So calculate the 1's complement of the result, i.e.,
00010, which is the negative number and the final answer.
Example 3: Subtract (6)10 from (3)10 using 1's complement method.

(3)10 – (011)2 – Minuend


(6)10 – (110)2 – Subtrahend
1's complement of 110 → 001
Now, 011 + 001 = 100
There is no carry, so take 1's complement of sum 100 → 011
This is negative. – 011 i.e. – 3

3) Addition using 2's complement - There are three different cases possible when we add two binary
numbers using 2's complement, which is as follows:

Case 1: Addition of the positive number with a negative number when the positive number has
a greater magnitude.
Initially find the 2's complement of the given negative number. Sum up with the given positive number.
If we get the end-around carry 1 then the number will be a positive number and the carry bit will be
discarded and remaining bits are the final result.

Example: 1101 and -1001

Step 1 : First, find the 2's complement of the negative number 1001. So, for finding 2's
complement, change all 0 to 1 and all 1 to 0 or find the 1's complement of the number 1001. The
1's complement of the number 1001 is 0110, and add 1 to the LSB of the result 0110. So the 2's
complement of number 1001 is 0110+1=0111
Step 2 : Add both the numbers, i.e., 1101 and 0111;
1101+0111=1 0100
Step 3 : By adding both numbers, we get the end-around carry 1. We discard the end-around
carry. So, the addition of both numbers is 0100.

Case 2: Adding of the positive value with a negative value when the negative number has a
higher magnitude.
Initially, add a positive value with the 2's complement value of the negative number. Here, no end-
around carry is found. So, we take the 2's complement of the result to get the final result.
Note: The resultant is a negative value.

Example: 1101 and -1110

Step 1: First, find the 2's complement of the negative number 1110. So, for finding 2's
complement, add 1 to the LSB of its 1's complement value 0001.
0001+1=0010
Step 2 : Add both the numbers, i.e., 1101 and 0010;
1101+0010= 1111
Step 3 : Find the 2's complement of the result 1110 that is the final result. So, the 2's
complement of the result 1110 is 0001, and add a negative sign before the number so that we can
identify that it is a negative number.
Case 3: Addition of two negative numbers
In this case, first, find the 2's complement of both the negative numbers, and then we will add both these
complement numbers. In this case, we will always get the end-around carry, which will be added to the
LSB, and forgetting the final result, we will take the2's complement of the result.
Note: The resultant is a negative value.
Example: -1101 and -1110 in five-bit register

Step 1 : Firstly find the 2's complement of the negative numbers 01101 and 01110. So, for
finding 2's complement, we add 1 to the LSB of the 1's complement of these numbers. 2's
complement of the number 01110 is 10010, and 01101 is 10011.
Step 2 : We add both the complement numbers, i.e., 10001 and 10010;
10010+10011= 1 00101
Step 3 : By adding both numbers, we get the end-around carry 1. This carry is discarded and the
final result is the 2.s complement of the result 00101. So, the 2's complement of the result 00101
is 11011, and we add a negative sign before the number so that we can identify that it is a
negative number.

4) Subtraction using 2's complement - These are the following steps to subtract two binary numbers
using 2's complement

o In the first step, find the 2's complement of the subtrahend.


o Add the complement number with the minuend.
o If we get the carry by adding both the numbers, then we discard this carry and the result is
positive else take 2's complement of the result which will be negative.
This procedure stems from the fact that a subtraction operation can be changed to an addition
operation if the sign of the subtrahend is changed. This is demonstrated by the following
relationship.
(±A) – (+B) = (±A) + (–B)
(±A) – (–B) = (±A) + (+B)

Example 1: 10101 - 00111

We take 2's complement of subtrahend 00111, which is 11001. Now, sum them. So,
10101+11001 =1 01110.
In the above result, we get the carry bit 1. So we discard this carry bit and remaining is the final result
and a positive number.

Example 2: 10101 - 10111

We take 2's complement of subtrahend 10111, which comes out 01001. Now, we add both of the
numbers. So,
10101+01001 =11110.
In the above result, we didn't get the carry bit. So calculate the 2's complement of the result, i.e., 00010.
It is the negative number and the final answer.
Example 3: Subtract (110)2 from (1010)2 using 2's complement.

Minuend - 1010
Subtrahend - 0 1 1 0
2's complement of subtrahend is 1 0 0 1 + 1 = 1 0 1 0
So ,
1010
+ 1010
10100 Discard the carry, answer is 0 1 0 0 .

Example 4: Subtract 6 from 3 using 2's complement

Minuend - 011
Subtrahend - 1 1 0
2's complement of subtrahend is 0 0 1 + 1 = 0 1 0
So,
011
+ 010
1 0 1 This is already in 2's complement. So, the answer is – 3.

You might also like