TUpapers logo TUpapers.com

Explore TUpapers

Study materials and tools in one place.

  • Dashboard
  • Blog
  • Search
  • About

Follow us

TUpapers on Facebook
TUpapers on Instagram
Contact TUpapers on WhatsApp
TUpapers subreddit on Reddit
Student Dashboard Student Dashboard
TUpapers logo TUpapers.com
  • Blog
  • About

Support Us

Your support helps us for further development and maintenance of site and resources!

Bank QR code for payment
eSewa QR code for payment
Khalti QR code for payment

The best way to support TUpapers is by purchasing a Premium Suscription or Notes Every purchase directly funds new features, better study resources, and platform maintenance.

On this chapter

Introduction

All Chapters

Dashboard

Select a chapter to start reading

Digital Logic Notes | BITM Second Semester | TU Papers

1 Chapter 1 Preview

No preview available.

Notes for this subject are coming soon — check back later.

Student Dashboard

Continue Reading

Get full notes inside the dashboard, along with other study tools.

Unit 1: Introduction [6 Hours]

Digital systems represent, process, store, and communicate information using discrete values, most commonly binary 0 and 1. This unit begins with analog and digital signals, then develops the ideas behind digital systems and the Integrated Circuit (IC). It also covers number systems, digital codes such as Binary-Coded Decimal (BCD), Gray and Excess-3, character representation, binary arithmetic, complements, and signed-number representation. Together, these ideas form the basic language used to represent data inside digital electronic and computing systems.

Tested Topics

  1. Gray code and conversion — 3x (2024, April 2023, October 2023)
  2. Number-system conversion — 3x (2024, April 2023, October 2023)
  3. BCD code and arithmetic — 2x (2024, 2024)
  4. Digital system fundamentals — 2x (April 2023, October 2023)
  5. Binary data combinations — 1x (April 2023)
  6. Digital IC characteristics — 1x (Model Q)
  7. Two's-complement arithmetic — 1x (October 2023)

1.1 Digital Versus Analog Signals

Definition

An analog signal is a signal whose value can change continuously over a range, whereas a digital signal represents information using a limited set of discrete levels, commonly logic 0 and logic 1.


An analog signal can take many values between its minimum and maximum. A digital signal works with separate, recognizable levels. For example, the continuously changing voltage produced by a microphone is analog, while the sequence of binary values stored in a computer is digital.

Detailed Explanation

A signal is a physical quantity that carries information. Voltage, current, light intensity, pressure, sound level, and radio-wave amplitude can all be used as signals.

The key difference between analog and digital representation is how possible values are treated.

  • Analog: information varies continuously with time or amplitude.
  • Digital: information is represented using distinct states or ranges.
Comparison of continuously varying analog signal and discrete digital logic levels

Analog Signal

An analog signal may take any value within its allowed range. If a temperature sensor produces 0 to 5 volts, its output might be 1.72 V, 1.721 V, 1.7214 V, or another value permitted by the physical system.

Natural physical quantities are commonly analog before they are measured and digitally encoded. Examples include:

  • sound pressure produced by speech,
  • room temperature,
  • light intensity,
  • speed of a moving vehicle,
  • air pressure,
  • the voltage generated by many sensors.

Digital Signal

A digital signal uses a finite number of recognizable levels. In binary digital electronics, two logical states are used:

  • logic 0, commonly called LOW,
  • logic 1, commonly called HIGH.

Logic 0 and logic 1 do not necessarily mean exactly 0 V and exactly one particular higher voltage. A real digital circuit normally recognizes a range of voltages as LOW and another range as HIGH. This allows the circuit to tolerate a certain amount of electrical noise.

Comparison of Analog and Digital Signals

BasisAnalog SignalDigital Signal
ValuesContinuous valuesDiscrete values
Typical representationSmoothly varying waveformDistinct logic levels or pulses
Noise effectNoise directly changes the signal valueSmall disturbances can often be rejected while the signal remains within valid logic ranges
StorageRequires analog recording or representationCan be conveniently stored as binary data
ProcessingPerformed using analog circuitsPerformed using digital logic circuits
CopyingSuccessive copies may accumulate distortionBinary information can be regenerated from valid logic states
ExamplesMicrophone voltage, analog thermometer outputComputer data, digital clock data, binary communication

Why Digital Representation Is Widely Used

Digital systems are attractive because information can be represented by a small number of clearly separated states. A receiving circuit does not need to reproduce the exact transmitted voltage. It mainly needs to decide which logical state the voltage represents.

This leads to several practical benefits:

  • Noise tolerance: moderate disturbances may not change the interpreted logic value.
  • Reliable storage: data can be stored as bit patterns.
  • Programmable processing: the same hardware can execute many operations under software control.
  • Easy duplication: valid binary states can be regenerated rather than continuously copied with accumulated analog error.
  • Integration: very large numbers of digital components can be manufactured together on semiconductor chips.

Let's Clarify

A traditional mercury thermometer gives a useful analogy for analog information. The mercury level may stop at any position along the scale. A digital thermometer instead reports a selected numerical value such as 27.4°C. The physical temperature still changes continuously, but the digital system represents the measurement using discrete numerical data.

Common Mistake

A digital signal is not defined merely as a square-shaped waveform. The defining idea is discrete information states. Real digital signals have finite rise and fall times and may not look like perfect mathematical rectangles.

Summary

  • Analog signals can take continuously varying values.
  • Digital signals represent information using discrete states, commonly binary 0 and 1.
  • Digital logic usually interprets voltage ranges as LOW and HIGH rather than requiring exact voltage values.
  • Digital representation supports reliable storage, regeneration, processing, and integration.
  • Many real-world quantities begin as analog signals and are later represented digitally.

Test Yourself

  1. Differentiate between analog and digital signals.
  2. Why can a binary digital signal tolerate moderate electrical noise?

Hints:

  1. Analog uses continuous values; digital uses discrete states. Compare value range, noise behavior, storage, and processing.
  2. Digital circuits recognize ranges as logic 0 and logic 1, so small voltage disturbances may still remain inside the correct valid range.

1.2 Digital Integrated Circuits

Definition

A digital integrated circuit is a semiconductor circuit in which many digital electronic components, such as transistors and logic gates, are fabricated together on a single small chip.


Instead of building every logic gate from separate physical components, an IC places many connected electronic elements inside one semiconductor package. Modern digital devices can therefore perform complex operations using compact, reliable chips.

Detailed Explanation

An integrated circuit combines active and passive electronic elements on a common semiconductor substrate. Digital ICs are specifically designed to operate with discrete logical states.

Examples of functions implemented by digital ICs include:

  • logic gates,
  • adders,
  • counters,
  • registers,
  • memory circuits,
  • processors,
  • digital controllers.

Advantages of Digital Integrated Circuits

  • Small physical size: many components occupy a tiny chip area.
  • Low weight: a chip replaces large assemblies of discrete components.
  • High reliability: fewer external connections reduce failure points.
  • High operating speed: very short internal connections reduce signal travel time and unwanted electrical effects.
  • Low cost per function: semiconductor fabrication produces large numbers of identical circuits.
  • Low power requirement: many modern digital IC technologies operate with small power per logic operation.
  • Easy system construction: standardized ICs can be connected to build larger digital systems.
  • High functional density: complex processing and memory functions can fit inside a compact package.

Major Characteristics of Digital ICs

The behavior of a digital IC is described using several electrical and timing characteristics.

CharacteristicMeaning
Logic levelsVoltage ranges recognized as logical LOW and logical HIGH.
Fan-inNumber of inputs that a logic gate is designed to accept.
Fan-outNumber of standard logic inputs that one output can reliably drive.
Propagation delayTime required for a change at an input to produce the corresponding change at the output.
Power dissipationElectrical power consumed and converted mainly into heat during operation.
Noise marginAmount of unwanted voltage disturbance that can be tolerated without changing the interpreted logic state.
Supply voltageOperating voltage required to power the IC.
Speed-power productA combined measure involving propagation delay and power dissipation, traditionally used when comparing logic technologies.

Propagation Delay

No real logic gate responds instantaneously. If an input changes from 0 to 1, the output changes a short time later. This interval is the propagation delay.

Smaller propagation delay → faster switching → potentially higher digital-system operating speed.

Fan-Out

One logic output may need to drive several following gates. If it drives too many, the voltage or current may leave the guaranteed operating conditions. Fan-out therefore indicates the permitted loading of a digital output.

Noise Margin

Suppose a receiving gate recognizes a range of input voltages as logical HIGH. If unwanted electrical interference slightly changes the voltage but the value remains inside the valid HIGH range, the logical state remains correct. The available tolerance is related to the noise margin.

Levels of Integration

The level of integration describes how much digital circuitry is integrated on one chip. As semiconductor technology improved, the number of gates or transistors that could be manufactured on a single IC increased dramatically.

Progression of digital integrated circuit integration levels from SSI through ULSI

The exact numerical boundaries used for integration levels vary between textbooks and historical technology generations. The following classification gives the common progression.

LevelGeneral ScaleTypical Functions
Small-Scale Integration (SSI)A small number of logic gates, traditionally fewer than about 10 gatesBasic gates, flip-flops
Medium-Scale Integration (MSI)Tens to roughly hundreds of gatesAdders, counters, multiplexers, decoders
Large-Scale Integration (LSI)Hundreds to many thousands of gatesEarly memory devices and complex functional blocks
Very-Large-Scale Integration (VLSI)Very large numbers of gates and transistorsModern processors, memory chips, controllers
Ultra-Large-Scale Integration (ULSI)Extremely high transistor density, commonly millions or moreHighly complex processors and system-scale chips

Why Increasing Integration Matters

More integration places more functions inside one chip. This reduces the number of separate packages and external wiring required for a complete system.

Higher integration → shorter internal connections → smaller size and often higher speed → lower cost per function → greater system complexity in a compact device.

Let's Clarify

Consider building a calculator from separate logic gates. With low integration, many individual chips and connecting wires are required. At higher integration levels, the arithmetic, control, storage, and interface functions can be combined into a much smaller number of chips. The calculation performed may be the same, but the physical implementation becomes dramatically more compact.

Common Mistake

Fan-in and fan-out describe different directions. Fan-in concerns how many inputs belong to a gate. Fan-out concerns how many following logic inputs one output can drive reliably.

Summary

  • A digital IC integrates many digital electronic components on one semiconductor chip.
  • Important advantages include compact size, high reliability, high speed, low cost per function, and high functional density.
  • Major characteristics include logic levels, fan-in, fan-out, propagation delay, power dissipation, and noise margin.
  • Integration levels progress from SSI and MSI through LSI, VLSI, and ULSI.
  • Higher integration allows increasingly complex digital systems to occupy fewer physical components.

Test Yourself

  1. Explain propagation delay, fan-out, and noise margin in a digital IC.
  2. Differentiate SSI, MSI, LSI, VLSI, and ULSI.
  3. List out the major characteristics of IC. (Model Q)

Hints:

  1. Propagation delay is input-to-output response time; fan-out is the number of standard inputs one output can drive; noise margin is the tolerated voltage disturbance.
  2. They represent progressively increasing levels of circuit integration, from a few logic gates to very large and extremely dense transistor systems.
  3. Include logic levels, fan-in, fan-out, propagation delay, power dissipation, noise margin, supply voltage, and speed-related characteristics.

1.3 Digital Systems and Their Applications

Definition

A digital system is an electronic system that represents and processes information using discrete values, usually binary digits 0 and 1.


A digital system receives information in coded form, processes it using digital logic, may store it, and produces an output. Computers, calculators, digital clocks, communication equipment, and embedded controllers are examples.

Detailed Explanation

Digital systems operate on bits. A bit, short for binary digit, can have one of two values: 0 or 1. Groups of bits can represent numbers, letters, instructions, images, sound samples, addresses, or control signals.

Basic Functional Flow of a Digital System

A general digital system can be understood using this sequence:

Input → digital representation → processing → storage when required → output

  • Input: information enters from switches, keyboards, sensors, communication links, or stored data.
  • Representation: information is expressed using binary patterns or another digital code.
  • Processing: logic circuits perform arithmetic, comparison, selection, decision-making, and control operations.
  • Storage: data or instructions may be retained in registers, memory, or other digital storage.
  • Output: the result is sent to a display, actuator, communication interface, file, or another digital system.

Combinational and Sequential Behavior

Digital circuits can broadly exhibit two forms of behavior:

  • Combinational logic: the output depends on the current input values.
  • Sequential logic: the output depends on current inputs and previously stored state.

An adder is an example of combinational logic. A counter is an example of sequential logic because it remembers its previous count.

Applications of Digital Systems

Application AreaDigital-System RoleExamples
ComputingPerforms arithmetic, logic, control, storage, and program executionDesktop computers, laptops, servers
CommunicationEncodes, processes, transmits, receives, and corrects digital informationMobile networks, routers, digital broadcasting
Consumer electronicsControls functions and processes digital mediaTelevisions, cameras, game systems
Industrial controlMonitors machines and performs automatic control decisionsFactory automation and process controllers
TransportationControls subsystems and processes sensor informationVehicle control systems and digital dashboards
Medical systemsProcesses measurements and controls diagnostic equipmentPatient monitors and imaging equipment
Banking and commerceStores and processes transaction informationAutomated payment and account-processing systems
Scientific instrumentationAcquires, analyzes, and records measured dataDigital measurement and laboratory systems

Why Binary Is Used

Binary representation works well with electronic circuits because two separated operating regions are easier to distinguish reliably than many closely spaced voltage levels.

Two stable logical states → binary representation → logic operations → complex computation from combinations of simple decisions.

Let's Clarify

A digital attendance system may receive a student identifier as input, compare it with stored records, update the attendance state, and show confirmation. The user sees names and dates, but internally those characters, numbers, comparisons, and stored records are all represented by binary patterns.

Summary

  • A digital system processes information represented by discrete states, usually binary 0 and 1.
  • Its general flow is input → representation → processing → optional storage → output.
  • Bits can represent numbers, characters, instructions, multimedia data, and control information.
  • Digital systems are used in computing, communication, industry, medicine, transportation, commerce, and instrumentation.
  • Binary operation is practical because two distinct electronic states can be recognized reliably.

Test Yourself

  1. Describe the basic functional flow of a digital system.
  2. What is digital system? (April, 2023)
  3. Define Digital System. (October, 2023)

Hints:

  1. Input → digital representation → processing → storage if required → output.
  2. An electronic system that represents and processes information using discrete values, normally binary 0 and 1.
  3. Define it in terms of discrete binary information and mention processing, storage, and output functions.

1.4 Digital Codes and Conversions

Definition

A digital code is an agreed pattern of binary digits used to represent numbers, characters, symbols, or other information inside a digital system.


The same bit pattern has no universal meaning by itself. A system needs a rule that explains what each pattern represents. One code may interpret a pattern as a decimal digit, another as a character, and another as a position or state.

Detailed Explanation

Binary circuits naturally work with 0s and 1s, but users work with decimal numbers, alphabetic characters, punctuation, and many other kinds of information. A code provides the mapping between meaningful information and binary patterns.

Comparison of binary patterns used in BCD Excess-3 Gray ASCII and EBCDIC codes

Why Digital Codes Are Needed

  • Representation: they allow human information to be expressed in binary form.
  • Processing: hardware can operate on coded data.
  • Storage: coded information can be placed in digital memory.
  • Communication: sender and receiver can interpret the same bit patterns consistently.
  • Special properties: some codes are designed to reduce transition errors or make particular arithmetic operations easier.

Main Categories in This Unit

Code or RepresentationMain PurposeBasic Idea
Pure binaryRepresent integer or fractional numerical valuesPositional base-2 notation
BCDRepresent decimal digits separatelyEach decimal digit gets its own 4-bit binary code
Excess-3Decimal digit codingAdd 3 to each decimal digit and encode the result in 4-bit binary
Gray codeOrder values with one-bit transitionsAdjacent code words differ in exactly one bit
Alphanumeric codesRepresent letters, digits, punctuation, and control symbolsAssign a binary code to each character

Weighted and Non-Weighted Codes

A weighted code assigns a positional weight to each bit. The represented value can be found by summing the weights corresponding to bits that are 1.

The standard 8421 BCD code is weighted because its four positions have weights 8, 4, 2, and 1.

A non-weighted code does not assign fixed arithmetic positional weights in that manner. Gray code and Excess-3 are normally treated as non-weighted codes.

Code Conversion

Code conversion means changing information from one representation to another while preserving its intended meaning.

Examples:

  • decimal digit → BCD,
  • BCD → decimal digit,
  • binary → Gray code,
  • Gray code → binary,
  • character → alphanumeric binary code.

Conversion must follow the rules of both the source code and the destination code. A bit-by-bit copy is not generally valid because two coding systems may assign different meanings to the same pattern.

Common Mistake

A number system and a digital code are related but not identical ideas. Binary is a positional number system. BCD uses binary patterns to encode individual decimal digits. Therefore the BCD representation of a multi-digit decimal number is usually different from the pure binary representation of the same numerical value.

Summary

  • A digital code assigns defined meanings to binary patterns.
  • Codes represent numerical data, characters, symbols, states, or other information.
  • BCD is a weighted decimal-digit code, while Excess-3 and Gray code are non-weighted codes.
  • Code conversion changes representation without changing the intended information.
  • The same bits can mean different things under different coding rules.

Test Yourself

  1. What is a digital code, and why is code conversion required?
  2. Differentiate a weighted code from a non-weighted code.
  3. Why is pure binary not the same as BCD?

Hints:

  1. A digital code maps information to binary patterns; conversion is needed when different systems or operations require different representations.
  2. A weighted code has defined positional weights; a non-weighted code does not use fixed arithmetic weights for its bit positions.
  3. Pure binary encodes the complete number as one base-2 value; BCD separately encodes every decimal digit using four bits.

1.5 Decimal, Binary, Octal, and Hexadecimal Number Systems

Definition

A number system is a method of representing numerical values using a set of symbols and a base, also called a radix, that determines the positional weights of those symbols.


Decimal uses ten digit symbols, binary uses two, octal uses eight, and hexadecimal uses sixteen. The position of a digit tells how much that digit contributes to the total value.

Detailed Explanation

Modern digital systems rely heavily on positional number systems. In a positional system, the value of a digit depends on both the digit itself and its position.

Place-value representation of digits using powers of the number-system base

General Positional Form

For a base r, a number with integer and fractional positions can be expanded as:

N = dnrn + ... + d1r1 + d0r0 + d-1r-1 + d-2r-2 + ...

Here:

  • r = base or radix,
  • d = digit at a position,
  • positive powers represent integer positions,
  • negative powers represent fractional positions.

Decimal Number System

The decimal number system has base 10 and uses the digits:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Example:

(572.4)10

= 5 × 102 + 7 × 101 + 2 × 100 + 4 × 10-1

= 500 + 70 + 2 + 0.4

= 572.4

Binary Number System

The binary number system has base 2 and uses:

0 and 1

Each binary digit is called a bit.

Example:

(101101)2

= 1 × 25 + 0 × 24 + 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20

= 32 + 8 + 4 + 1

= (45)10

Most Significant and Least Significant Bits

In a binary number, the leftmost position with the greatest positional weight is the most significant bit (MSB). The rightmost bit of the integer part has the smallest integer positional weight and is called the least significant bit (LSB).

Binary Data Combinations

If a binary word contains n bits, each bit has two possible states. Therefore the total number of different binary patterns is:

Number of combinations = 2n

For 5 bits:

25 = 32 combinations

The patterns extend from:

00000 through 11111

If interpreted as unsigned binary integers, these 32 combinations represent decimal values from 0 to 31.

Octal Number System

The octal number system has base 8 and uses:

0, 1, 2, 3, 4, 5, 6, 7

Each octal digit corresponds exactly to three binary bits because:

8 = 23

Examples:

OctalBinary
0000
1001
2010
3011
4100
5101
6110
7111

Hexadecimal Number System

The hexadecimal number system has base 16. It uses:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

The alphabetic digits have these decimal values:

Hexadecimal DigitDecimal ValueBinary Equivalent
A101010
B111011
C121100
D131101
E141110
F151111

Each hexadecimal digit corresponds to four binary bits because:

16 = 24

Comparison of the Four Number Systems

Number SystemBaseAllowed DigitsBinary Relationship
Decimal100 to 9No fixed whole-bit grouping
Binary20, 1Native digital representation
Octal80 to 71 octal digit = 3 binary bits
Hexadecimal160 to 9, A to F1 hexadecimal digit = 4 binary bits

Common Mistake

A digit that is valid in one base may be invalid in another. For example, 8 cannot appear inside an octal number, and 2 cannot appear inside a binary number.

Summary

  • Decimal, binary, octal, and hexadecimal use bases 10, 2, 8, and 16 respectively.
  • Positional value is determined by digit × baseposition.
  • One octal digit maps to three binary bits; one hexadecimal digit maps to four binary bits.
  • An n-bit binary word has 2n possible bit combinations.
  • Hexadecimal uses A through F to represent decimal values 10 through 15.

Test Yourself

  1. How many combinations can be represented by an 8-bit binary word?
  2. Explain why one octal digit corresponds to three binary bits.
  3. How many different combination can be represented by 5-bit binary data? (April, 2023)

Hints:

  1. 28 = 256 combinations.
  2. Three bits provide 23 = 8 patterns, exactly matching the eight octal digits 0 through 7.
  3. 25 = 32 different combinations.

1.6 Number-System Conversion

Definition

Number-system conversion is the process of expressing the same numerical value in a different base without changing its quantity.


A value such as decimal 45, binary 101101, octal 55, and hexadecimal 2D can all represent the same quantity. Conversion changes the notation, not the value.

Detailed Explanation

Conversions among decimal, binary, octal, and hexadecimal follow different methods depending on the source and destination bases.

Conversion map among decimal binary octal and hexadecimal number systems

Binary to Decimal

Multiply each binary digit by its positional power of 2 and add the results.

Example:

(110101.101)2

= 1×25 + 1×24 + 0×23 + 1×22 + 0×21 + 1×20 + 1×2-1 + 0×2-2 + 1×2-3

= 32 + 16 + 4 + 1 + 0.5 + 0.125

= (53.625)10

Octal to Decimal

Use positional powers of 8.

(725.4)8

= 7×82 + 2×81 + 5×80 + 4×8-1

= 448 + 16 + 5 + 0.5

= (469.5)10

Hexadecimal to Decimal

Use positional powers of 16 and replace A through F by decimal values 10 through 15.

Example:

(2A3B.2A)16

= 2×163 + 10×162 + 3×161 + 11×160 + 2×16-1 + 10×16-2

= 8192 + 2560 + 48 + 11 + 0.125 + 0.0390625

= (10811.1640625)10

Decimal Integer to Binary, Octal, or Hexadecimal

For the integer part, repeatedly divide by the destination base and record the remainders.

The remainders are read from bottom to top.

Example: convert (45)10 to binary.

DivisionQuotientRemainder
45 ÷ 2221
22 ÷ 2110
11 ÷ 251
5 ÷ 221
2 ÷ 210
1 ÷ 201

Reading upward:

(45)10 = (101101)2

Decimal Fraction to Another Base

For a fractional part, repeatedly multiply by the destination base. At each step, record the integer part of the result. Read the recorded integer digits from top to bottom.

Example: convert (0.625)10 to binary.

MultiplicationInteger PartRemaining Fraction
0.625 × 2 = 1.2510.25
0.25 × 2 = 0.500.5
0.5 × 2 = 1.010

Therefore:

(0.625)10 = (0.101)2

Binary to Octal

Because one octal digit corresponds to three binary bits:

  1. Start at the binary point.
  2. Group integer bits in sets of three moving left.
  3. Group fractional bits in sets of three moving right.
  4. Add zeros at the outside edges if a group is incomplete.
  5. Replace each group by the equivalent octal digit.

Example:

(101011.1101)2

Group:

101 011 . 110 100

Convert:

101 = 5, 011 = 3, 110 = 6, 100 = 4

Therefore:

(101011.1101)2 = (53.64)8

Binary to Hexadecimal

Group binary digits in sets of four around the binary point.

Using the same number:

(101011.1101)2

Pad and group:

0010 1011 . 1101

0010 = 2, 1011 = B, 1101 = D

Therefore:

(101011.1101)2 = (2B.D)16

Octal to Binary

Replace each octal digit with its 3-bit binary equivalent.

Example:

(572)8

5 → 101
7 → 111
2 → 010

Therefore:

(572)8 = (101111010)2

Hexadecimal to Binary

Replace each hexadecimal digit with its 4-bit binary equivalent.

Example:

(2A3B.2A)16

2 → 0010
A → 1010
3 → 0011
B → 1011
2 → 0010
A → 1010

Therefore:

(2A3B.2A)16 = (0010101000111011.00101010)2

Leading zeros in the integer part may be omitted:

(10101000111011.00101010)2

Hexadecimal to Octal Through Binary

For bases 16 and 8, binary provides an efficient intermediate form.

For (2A3B.2A)16:

Hexadecimal:

2 A 3 B . 2 A

Binary:

0010 1010 0011 1011 . 0010 1010

Regroup into three bits:

000 010 101 000 111 011 . 001 010 100

Octal digits:

0 2 5 0 7 3 . 1 2 4

Drop the unnecessary leading zero:

(2A3B.2A)16 = (25073.124)8

Worked Conversion: (2A31)16

Decimal:

2×163 + 10×162 + 3×16 + 1

= 8192 + 2560 + 48 + 1

= (10801)10

Binary:

2 A 3 1 → 0010 1010 0011 0001

Therefore:

(2A31)16 = (10101000110001)2

Octal:

Binary regrouping:

000 010 101 000 110 001

= (25061)8

Let's Clarify

The direction of reading is different for the two decimal-conversion procedures. Repeated division handles the integer part and produces remainders from least significant to most significant, so the remainders are read upward. Repeated multiplication handles the fractional part and directly produces digits from most significant fractional position onward, so those digits are read downward.

Common Mistake

When grouping binary digits for octal or hexadecimal, zeros may be added only at the outer ends: to the left of the integer part or to the right of the fractional part. Inserting zeros near the binary point would change the numerical value.

Summary

  • To convert any positional number to decimal, expand it using powers of its base.
  • Decimal integers convert by repeated division; decimal fractions convert by repeated multiplication.
  • Binary and octal convert directly using groups of three bits.
  • Binary and hexadecimal convert directly using groups of four bits.
  • Octal and hexadecimal can be converted efficiently through an intermediate binary representation.

Test Yourself

  1. Convert (110101.101)2 into decimal.
  2. Convert (101011.1101)₂ to Octal and Hexadecimal form. (2024)
  3. Convert 2A3B.2A₁₆ into binary, octal and decimal. (April, 2023)
  4. Convert (2A31)₁₆ into decimal, binary and octal form. (October, 2023)

Hints:

  1. Use powers of 2. Result: (53.625)10.
  2. Group by three for octal and four for hexadecimal. Results: (53.64)8 and (2B.D)16.
  3. Binary: 10101000111011.00101010; octal: 25073.124; decimal: 10811.1640625.
  4. Decimal: 10801; binary: 10101000110001; octal: 25061.

1.7 Binary-Coded Decimal Code and Arithmetic

Definition

Binary-Coded Decimal represents each decimal digit separately by its 4-bit binary equivalent. The most common form is the 8421 BCD code.


BCD does not convert the whole decimal number into one binary value. Instead, every decimal digit keeps its identity and receives four binary bits.

Detailed Explanation

The four BCD positions have weights:

8, 4, 2, 1

Therefore decimal digits 0 through 9 are represented as follows:

Decimal Digit8421 BCD
00000
10001
20010
30011
40100
50101
60110
70111
81000
91001

The six remaining 4-bit patterns, from 1010 through 1111, are not valid decimal digits in standard 8421 BCD.

Decimal to BCD

Convert each decimal digit independently.

Example:

(279)10

2 → 0010
7 → 0111
9 → 1001

Therefore:

(279)10 = 0010 0111 1001 in BCD

BCD to Decimal

Split the BCD value into groups of four bits and convert each valid group into its corresponding decimal digit.

Example:

0101 1000 0011

0101 → 5
1000 → 8
0011 → 3

Therefore the decimal value is:

583

BCD Versus Pure Binary

Consider decimal 25.

BCD:

2 → 0010
5 → 0101

So:

25 = 0010 0101 in BCD

Pure binary:

25 = 110012

The two bit patterns are different because they use different representation rules.

BCD Addition

BCD addition begins with ordinary binary addition of corresponding 4-bit decimal-digit groups. A correction is required whenever a digit result is not a valid BCD digit.

BCD Correction Rule

After adding a 4-bit decimal digit, add 0110 if either condition occurs:

  • the 4-bit result is greater than 1001, or
  • the addition produces a carry out of the 4-bit group.

Why 0110? Four bits can represent sixteen patterns, but BCD uses only ten of them for decimal digits. Adding 6 corrects a binary result in the invalid region and produces the proper decimal carry relationship.

Worked Example: 279 + 799 Using BCD

First encode both numbers:

279 = 0010 0111 1001

799 = 0111 1001 1001

Work from the rightmost decimal digit.

Step 1: Ones column

9 + 9:

1001 + 1001 = 10010

A carry occurs, so apply BCD correction:

10010 + 00110 = 11000

Keep the lower four bits 1000, representing 8, and carry 1 to the tens digit.

Step 2: Tens column

7 + 9 + carry 1:

0111 + 1001 + 0001 = 10001

Correct:

10001 + 00110 = 10111

Keep 0111, representing 7, and carry 1.

Step 3: Hundreds column

2 + 7 + carry 1:

0010 + 0111 + 0001 = 1010

1010 is greater than valid BCD 1001, so add 0110:

1010 + 0110 = 10000

Keep 0000 and carry 1 to a new thousands digit.

Final BCD result:

0001 0000 0111 1000

Decode:

0001 → 1
0000 → 0
0111 → 7
1000 → 8

Therefore:

(279)10 + (799)10 = (1078)10

Let's Clarify

BCD arithmetic keeps decimal digit boundaries visible. That is why a result such as binary 1010 cannot be accepted as one BCD digit. Decimal has no single digit with value 10. The result must become decimal 10, meaning digit 0 with a carry of 1 to the next decimal position.

Common Mistake

Do not treat the complete BCD bit string as one ordinary binary number. In BCD, every group of four bits represents one decimal digit independently.

Summary

  • 8421 BCD represents each decimal digit separately using four bits.
  • Valid BCD digit patterns range from 0000 through 1001.
  • The patterns 1010 through 1111 are invalid as individual BCD decimal digits.
  • BCD addition begins with binary addition of each 4-bit digit group.
  • If a digit result exceeds 1001 or generates a carry, add 0110 as a correction.

Test Yourself

  1. Convert decimal 593 into 8421 BCD.
  2. What is BCD code? (2024)
  3. Find the value of (279)₁₀ + (799)₁₀ by converting it to BCD data. (2024)

Hints:

  1. 5 → 0101, 9 → 1001, 3 → 0011, giving 0101 1001 0011.
  2. BCD represents each decimal digit separately by a 4-bit binary code, commonly with 8421 positional weights.
  3. Encode as 0010 0111 1001 and 0111 1001 1001; apply correction 0110 where required. Final BCD = 0001 0000 0111 1000 = 1078.

1.8 Excess-3 Code

Definition

Excess-3 code is a 4-bit decimal digit code obtained by adding 3 to each decimal digit and then writing the result as a 4-bit binary number.


To encode a decimal digit in Excess-3, increase that digit by three first. For example, decimal 5 becomes 8, and binary 1000 is therefore the Excess-3 code for decimal 5.

Detailed Explanation

Excess-3 is a non-weighted code. Its bit positions are not interpreted as ordinary 8-4-2-1 weights for directly recovering the original decimal digit.

Excess-3 Code Table

Decimal DigitAdd 3Excess-3 Code
030011
140100
250101
360110
470111
581000
691001
7101010
8111011
9121100

Decimal to Excess-3

Example: encode decimal 59.

Digit 5:

5 + 3 = 8 → 1000

Digit 9:

9 + 3 = 12 → 1100

Therefore:

59 = 1000 1100 in Excess-3

Excess-3 to Decimal

Reverse the process:

  1. Split the code into 4-bit groups.
  2. Convert each group to its ordinary binary value.
  3. Subtract 3 from each value.

Example:

0111 1011

0111 = 7 → 7 − 3 = 4

1011 = 11 → 11 − 3 = 8

Therefore:

0111 1011 represents decimal 48

Self-Complementing Property

Excess-3 is a self-complementing decimal code. Complementing all four bits of an Excess-3 digit produces the Excess-3 representation of that digit's 9's complement.

Example:

Decimal 2 → Excess-3 = 0101

Bit complement → 1010

1010 is Excess-3 for decimal 7.

Since 7 is the 9's complement of 2:

9 − 2 = 7

BCD and Excess-3 Comparison

Feature8421 BCDExcess-3
TypeWeightedNon-weighted
Encoding methodDirect 4-bit binary value of decimal digitAdd 3, then encode in binary
Code for decimal 000000011
Self-complementingNoYes
Code for decimal 910011100

Summary

  • Excess-3 encodes each decimal digit after adding 3.
  • It is a non-weighted 4-bit decimal code.
  • Decoding requires converting the group to binary value and subtracting 3.
  • Its valid decimal digit codes range from 0011 through 1100.
  • Excess-3 is self-complementing with respect to decimal 9's complements.

Test Yourself

  1. Convert decimal 72 into Excess-3 code.
  2. Decode the Excess-3 number 1001 0100.
  3. Why is Excess-3 called a self-complementing code?

Hints:

  1. 7 + 3 = 10 → 1010; 2 + 3 = 5 → 0101. Result: 1010 0101.
  2. 1001 = 9, subtract 3 → 6; 0100 = 4, subtract 3 → 1. Decimal 61.
  3. Bitwise complement of an Excess-3 digit produces the Excess-3 code for its 9's-complement decimal digit.

1.9 Gray Code and Conversion

Definition

Gray code is a binary coding system in which any two consecutive code words differ in only one bit position.


When a Gray-coded value changes to its next adjacent value, only one bit changes. This reduces ambiguity in systems where several ordinary binary bits might otherwise change almost simultaneously.

Detailed Explanation

Gray code is a non-weighted and unit-distance code. Unit-distance means adjacent values differ by a Hamming distance of one, which here means one bit changes.

Binary-to-Gray and Gray-to-binary conversion using XOR relationships

Why Gray Code Is Useful

Consider the ordinary binary transition from decimal 7 to decimal 8:

7 = 0111

8 = 1000

All four bits change. In a real electromechanical or asynchronous sensing system, the bits may not physically change at exactly the same instant. A receiver could briefly observe an unintended intermediate combination.

With Gray code, adjacent positions differ by one bit, which reduces this type of transition ambiguity.

Gray code is therefore useful in applications such as:

  • rotary and position encoders,
  • position sensing,
  • ordering used in Karnaugh maps,
  • systems where transition ambiguity should be minimized.

4-Bit Binary and Gray Sequence

DecimalBinaryGray
000000000
100010001
200100011
300110010
401000110
501010111
601100101
701110100
810001100
910011101
1010101111
1110111110
1211001010
1311011011
1411101001
1511111000

Binary to Gray Conversion

The conversion uses the Exclusive-OR (XOR) operation. XOR gives 1 when its two input bits are different and 0 when they are the same.

ABA XOR B
000
011
101
110

For binary-to-Gray conversion:

  1. Copy the binary MSB directly as the Gray MSB.
  2. For every following Gray bit, XOR the current binary bit with the binary bit immediately to its left.

Symbolically:

GMSB = BMSB

Next Gray bit = previous binary bit XOR current binary bit

Worked Example: Binary 1010 to Gray

Binary:

1 0 1 0

First Gray bit:

1

Second:

1 XOR 0 = 1

Third:

0 XOR 1 = 1

Fourth:

1 XOR 0 = 1

Therefore:

(1010)2 = (1111)Gray

Gray to Binary Conversion

For Gray-to-binary conversion:

  1. Copy the Gray MSB directly as the binary MSB.
  2. For each following bit, XOR the previous binary result bit with the current Gray bit.

Symbolically:

BMSB = GMSB

Next binary bit = previous binary bit XOR current Gray bit

Worked Example: Gray 1011 to Binary

Gray:

1 0 1 1

First binary bit:

1

Second:

1 XOR 0 = 1

Third:

1 XOR 1 = 0

Fourth:

0 XOR 1 = 1

Therefore:

(1011)Gray = (1101)2

Let's Clarify

Imagine a rotating shaft whose position is detected by several sensors. With ordinary binary, moving between adjacent positions may require several sensor bits to change. If one sensor reacts slightly earlier than another, a temporary wrong value may appear. Gray coding arranges adjacent positions so only one sensor bit must change, reducing this ambiguity.

Common Mistake

The XOR direction differs between the two conversions. Binary-to-Gray compares adjacent original binary bits. Gray-to-binary uses the previously calculated binary bit together with the current Gray bit.

Summary

  • Gray code is a non-weighted unit-distance code.
  • Adjacent Gray code words differ in exactly one bit.
  • Binary-to-Gray copies the MSB, then XORs adjacent binary bits.
  • Gray-to-binary copies the MSB, then XORs the previous binary result with the current Gray bit.
  • Gray code is useful where multiple-bit transitions could create ambiguous intermediate readings.

Test Yourself

  1. Convert binary 1101 into Gray code.
  2. Convert Gray code 1110 into binary.
  3. Convert (1010)₂ to gray code. (2024)
  4. What is gray code? (April, 2023)
  5. Convert gray code: 1011 to binary. (October, 2023)

Hints:

  1. Copy 1; then XOR adjacent binary bits: 1⊕1=0, 1⊕0=1, 0⊕1=1. Result 1011.
  2. Copy 1; then cumulative XOR: 1⊕1=0, 0⊕1=1, 1⊕0=1. Result 1011.
  3. 1, 1⊕0, 0⊕1, 1⊕0 → 1111.
  4. A non-weighted unit-distance code in which consecutive code words differ in exactly one bit.
  5. Copy first bit, then use previous binary bit XOR current Gray bit. Result: 1101.

1.10 Alphanumeric Codes: American Standard Code for Information Interchange and Extended Binary Coded Decimal Interchange Code

Definition

An alphanumeric code assigns binary patterns to letters, decimal digits, punctuation marks, control characters, and other symbols so that textual information can be stored, processed, and transmitted digitally.


Computers do not store the visible shape of a letter such as A as the letter itself. A character-encoding system assigns a numerical code to A, B, 0, 1, punctuation marks, and control symbols, and that numerical code is stored in binary form.

Detailed Explanation

Two historically important alphanumeric codes are the American Standard Code for Information Interchange (ASCII) and the Extended Binary Coded Decimal Interchange Code (EBCDIC).

American Standard Code for Information Interchange

Standard ASCII is a 7-bit character code. Seven bits provide:

27 = 128 possible codes

These codes represent:

  • uppercase letters,
  • lowercase letters,
  • decimal digits,
  • punctuation marks,
  • special symbols,
  • control characters.

Selected ASCII Values

CharacterDecimal Code7-Bit Binary
Space320100000
0480110000
1490110001
A651000001
B661000010
a971100001
b981100010

A useful observation is that ASCII digits are characters. The character '5' is encoded as a character code and is not automatically the same bit representation used for the numerical binary value 5.

Extended ASCII Terminology

The phrase extended ASCII is commonly used for various 8-bit character sets whose first 128 positions correspond to ASCII. It does not refer to one single universal extension. Different historical systems used different assignments for the upper 128 values.

Extended Binary Coded Decimal Interchange Code

EBCDIC is an 8-bit character encoding historically associated mainly with International Business Machines (IBM) mainframe and midrange systems.

Eight bits provide:

28 = 256 possible code patterns

EBCDIC supports letters, numbers, punctuation, and control characters, but its numerical assignments differ from ASCII.

ASCII and EBCDIC Comparison

FeatureASCIIEBCDIC
Full formAmerican Standard Code for Information InterchangeExtended Binary Coded Decimal Interchange Code
Basic code length7 bits8 bits
Possible basic patterns128256
Historical useGeneral computers and communication systemsMainly IBM mainframe-oriented environments
Character assignmentsUses ASCII orderingUses a different coding arrangement

Why Character Codes Matter

For text to move correctly between storage, applications, and communication systems, the sender and receiver must agree on the meaning assigned to each numerical code.

Character → numerical code → binary storage or transmission → numerical code interpreted → character displayed

Common Mistake

The character '9' and the numerical value 9 are different concepts. The character '9' has a character code used for text. The numerical quantity 9 may be stored in ordinary binary, BCD, or another numerical representation depending on the system.

Summary

  • Alphanumeric codes map characters and control symbols to binary values.
  • Standard ASCII is a 7-bit code with 128 possible values.
  • EBCDIC is an 8-bit character encoding historically associated with IBM systems.
  • ASCII and EBCDIC assign different numerical patterns to characters.
  • Character coding allows textual information to be stored, processed, and transmitted digitally.

Test Yourself

  1. What is an alphanumeric code?
  2. Compare ASCII and EBCDIC.
  3. Why is the ASCII character '5' not identical to the binary numerical value 5?

Hints:

  1. A binary coding scheme that assigns numerical patterns to letters, digits, punctuation, symbols, and control characters.
  2. ASCII is basically 7-bit with 128 codes; EBCDIC is 8-bit with 256 patterns and historically associated with IBM mainframe systems.
  3. '5' is textual data and has a character-code value; numerical 5 represents the mathematical quantity five.

1.11 Binary Addition and Subtraction

Definition

Binary arithmetic applies arithmetic operations directly to numbers represented with binary digits 0 and 1. Binary addition and subtraction follow positional rules similar to decimal arithmetic but use base 2.


The method is familiar from decimal arithmetic: work column by column from right to left, carry when a column becomes too large, and borrow when the upper digit is too small. The difference is that each position has only two possible digits.

Detailed Explanation

Worked binary addition subtraction and complement arithmetic with bit columns

Binary Addition Rules

OperationSum BitCarry
0 + 000
0 + 110
1 + 010
1 + 101
1 + 1 + 111

Worked Binary Addition

Add:

10112 + 11012

   1011
 + 1101
 -------
  11000

Check in decimal:

10112 = 1110

11012 = 1310

11 + 13 = 24

110002 = 2410

Step-by-Step Addition

  1. Rightmost column: 1 + 1 = 10, write 0 and carry 1.
  2. Next column: 1 + 0 + carry 1 = 10, write 0 and carry 1.
  3. Next column: 0 + 1 + carry 1 = 10, write 0 and carry 1.
  4. Next column: 1 + 1 + carry 1 = 11, write 1 and carry 1.
  5. Place the final carry at the left, producing 11000.

Binary Subtraction Rules

OperationDifferenceBorrow
0 − 000
1 − 010
1 − 100
0 − 111 from the next higher position

When 1 is borrowed from the next binary position, its value in the current position is binary 10, which equals decimal 2.

Worked Binary Subtraction

Subtract:

110102 − 010112

   11010
 - 01011
 -------
   01111

Decimal check:

110102 = 2610

010112 = 1110

26 − 11 = 15

011112 = 1510

Carry Versus Borrow

  • Carry: moves a value into the next higher position during addition.
  • Borrow: takes one unit from the next higher position during subtraction.

Because each higher binary position has twice the weight of the position to its right, borrowing one unit supplies binary 10 at the current position.

Fixed-Width Unsigned Addition

When an unsigned result requires more bits than the fixed storage width provides, the extra carry indicates that the exact result cannot fit in that unsigned width.

For example, four unsigned bits can represent 0 through 15:

1111 + 0001 = 1 0000

The mathematical result is 16, which requires five bits.

Let's Clarify

Binary carrying is the base-2 version of decimal carrying. In decimal, 9 + 1 produces 10, so the current digit becomes 0 and 1 moves left. In binary, 1 + 1 already reaches the base, producing binary 10. The current bit becomes 0 and a carry of 1 moves left.

Summary

  • Binary arithmetic uses the digits 0 and 1 with base-2 positional rules.
  • 1 + 1 produces sum 0 and carry 1.
  • 1 + 1 + 1 produces sum 1 and carry 1.
  • For 0 − 1, borrow one binary unit from the next higher position, giving binary 10 in the current position.
  • Fixed-width unsigned arithmetic must have enough bits to contain the final result.

Test Yourself

  1. Add 1011012 and 0110112.
  2. Subtract 001112 from 101002.
  3. Why does borrowing one binary unit give 102 in the next lower position?

Hints:

  1. 45 + 27 = 72, so the binary result is 10010002.
  2. 20 − 7 = 13, so the result is 011012.
  3. Each position has twice the weight of the position to its right; one unit of the higher position therefore equals two units, written 102, in the lower position.

1.12 1's Complement and 2's Complement

Definition

The 1's complement of a binary number is formed by changing every 0 to 1 and every 1 to 0. The 2's complement is formed by taking the 1's complement and adding 1.


Complements provide a convenient way to represent negative binary values and perform subtraction using addition hardware. The 2's-complement system is especially useful because it has only one representation for zero.

Detailed Explanation

Finding 1's Complement

Take the binary value:

00101101

Invert every bit:

0 → 1
0 → 1
1 → 0
0 → 1
1 → 0
1 → 0
0 → 1
1 → 0

Therefore:

1's complement of 00101101 = 11010010

Finding 2's Complement

Begin with:

00101101

1's complement:

11010010

Add 1:

  11010010
+ 00000001
-----------
  11010011

Therefore:

2's complement of 00101101 = 11010011

Alternative Way to Form 2's Complement

A useful bit method is:

  1. Starting from the right, copy bits through and including the first 1.
  2. Invert every remaining bit to the left.

Example:

00101100

From the right, copy 100. Invert all bits to the left:

11010100

This gives the same result as invert-all-bits-and-add-1.

1's-Complement Subtraction

To calculate A − B using 1's complement:

  1. Write both values using the same fixed number of bits.
  2. Find the 1's complement of B.
  3. Add it to A.
  4. If a carry leaves the most significant position, add that carry back to the least significant position. This is called end-around carry.
  5. If no end-around carry is produced, the result is negative and is in 1's-complement form.

Example: 9 − 5 Using 1's Complement

Using 4 bits:

9 = 1001

5 = 0101

1's complement of 5:

1010

Add:

  1001
+ 1010
------
1 0011

Take the end-around carry 1 and add it to 0011:

0011
0001
----
0100

0100 = 4, so:

9 − 5 = 4

2's-Complement Subtraction

To calculate A − B:

  1. Use the same number of bits for A and B.
  2. Find the 2's complement of B.
  3. Add it to A.
  4. If a carry leaves the most significant position, discard that carry.
  5. Interpret the remaining fixed-width result.

Example: 13 − 5 Using 2's Complement

Using 5 bits:

13 = 01101

5 = 00101

1's complement of 00101:

11010

Add 1:

11011

Add to 13:

  01101
+ 11011
-------
1 01000

Discard the carry:

01000 = 8

Therefore:

13 − 5 = 8

Representing Negative Values with 2's Complement

To represent −20 using 8 bits:

+20:

00010100

Invert:

11101011

Add 1:

11101100

Therefore:

−20 = 11101100 in 8-bit 2's complement

Worked Example: (−20)10 + (+30)10

Use 8-bit 2's-complement representation.

+30:

00011110

−20:

+20 = 00010100

1's complement = 11101011

Add 1 = 11101100

Add:

  11101100
+ 00011110
-----------
1 00001010

Discard the carry outside the 8-bit width:

00001010

This is positive decimal 10.

Therefore:

(−20)10 + (+30)10 = (+10)10

Why 2's Complement Is Preferred

  • One zero representation: there is no separate positive zero and negative zero.
  • Addition hardware handles subtraction: subtraction can be implemented by adding the 2's complement.
  • Natural fixed-width wraparound: the final carry can be discarded.
  • Asymmetric useful range: one additional negative value is representable compared with sign-magnitude and 1's complement.

Comparison of 1's and 2's Complement

Feature1's Complement2's Complement
FormationInvert every bitInvert every bit and add 1
Zero formsTwoOne
Subtraction carryUses end-around carryFinal carry is discarded
n-bit negative range−(2n−1 − 1)−2n−1
Modern signed-integer useRareWidely used

Let's Clarify

The key idea is to replace subtraction with addition. Instead of building a completely separate arithmetic process for A − B, a digital system can form the complement representation of B and feed it into an adder. This is one reason complement systems are so closely connected to computer arithmetic.

Common Mistake

The fixed bit width must remain constant throughout complement arithmetic. If a problem uses 8 bits, every positive value, negative value, complement, carry decision, and final interpretation must be handled as an 8-bit quantity.

Summary

  • 1's complement is formed by inverting every bit.
  • 2's complement equals the 1's complement plus 1.
  • 1's-complement subtraction may require an end-around carry.
  • In fixed-width 2's-complement addition, a carry beyond the most significant bit is discarded.
  • 2's complement provides one zero representation and is widely used for signed binary integers.

Test Yourself

  1. Find the 1's and 2's complements of 00110110.
  2. Compute 18 − 7 using a 6-bit 2's-complement method.
  3. Compute (-20)₁₀ + (+30)₁₀, using 2's complement method. (October, 2023)

Hints:

  1. 1's complement = 11001001; 2's complement = 11001010.
  2. 18 = 010010; 7 = 000111; 2's complement of 7 = 111001. Add and discard carry to obtain 001011 = 11.
  3. 8-bit −20 = 11101100; +30 = 00011110; sum = 1 00001010. Discard carry → 00001010 = +10.

1.13 Signed Number Representation

Definition

Signed number representation is a binary method that allows both positive and negative integers to be encoded using a fixed number of bits.


Unsigned binary uses every bit to represent magnitude, so it cannot directly distinguish positive from negative values. Signed representations reserve or interpret the most significant bit in a way that identifies negative numbers.

Detailed Explanation

Three classical signed-integer representations are:

  • sign-magnitude,
  • 1's complement,
  • 2's complement.
Positive and negative integers represented using sign-magnitude ones complement and twos complement

Sign-Magnitude Representation

In sign-magnitude representation:

  • the MSB acts as a sign bit,
  • 0 indicates positive,
  • 1 indicates negative,
  • the remaining bits store the magnitude.

Using 8 bits, represent decimal 13.

Magnitude of 13 using 7 magnitude bits:

0001101

Positive:

+13 = 00001101

Negative:

−13 = 10001101

Two Zeros in Sign-Magnitude

Sign-magnitude has:

+0 = 00000000

−0 = 10000000

This duplicate zero representation is one disadvantage of the method.

1's-Complement Representation

A positive value is stored as ordinary binary with a leading sign bit 0. A negative value is obtained by complementing every bit of the positive representation.

Using 8 bits:

+13 = 00001101

Invert all bits:

−13 = 11110010

1's complement also has two representations for zero:

+0 = 00000000

−0 = 11111111

2's-Complement Representation

A positive value is represented normally. To represent the corresponding negative value:

  1. write the positive value using the fixed bit width,
  2. invert every bit,
  3. add 1.

For 8-bit −13:

+13:

00001101

Invert:

11110010

Add 1:

11110011

Therefore:

−13 = 11110011 in 8-bit 2's complement

One Zero in 2's Complement

2's complement has only:

00000000 = 0

There is no separate negative-zero bit pattern.

Range of n-Bit Signed Representations

Sign-Magnitude

One bit is used for the sign and n−1 bits represent magnitude.

Range = −(2n−1 − 1) to +(2n−1 − 1)

For 8 bits:

−127 to +127

1's Complement

The range is also:

−(2n−1 − 1) to +(2n−1 − 1)

For 8 bits:

−127 to +127

2's Complement

The range is:

−2n−1 to +(2n−1 − 1)

For 8 bits:

−128 to +127

Comparison of Signed Representations

FeatureSign-Magnitude1's Complement2's Complement
Negative formationSet sign bit to 1Invert all bitsInvert all bits and add 1
Positive representationOrdinary binary with sign 0Ordinary binary with sign 0Ordinary binary with sign 0
Number of zerosTwoTwoOne
n-bit range−(2n−1−1) to +(2n−1−1)−(2n−1−1) to +(2n−1−1)−2n−1 to +(2n−1−1)
Arithmetic convenienceRequires sign handlingRequires end-around carry in subtractionWorks naturally with fixed-width binary addition

Decoding a Negative 2's-Complement Number

Suppose an 8-bit value is:

11110110

The MSB is 1, so under signed 2's-complement interpretation it is negative.

Find its magnitude:

Invert:

00001001

Add 1:

00001010

00001010 = 10.

Therefore:

11110110 represents −10 in 8-bit 2's complement.

Unsigned Versus Signed Interpretation

The bit pattern itself does not state whether it is signed or unsigned. Its interpretation depends on the representation selected by the system.

For example:

11111111

  • as an 8-bit unsigned number → 255,
  • as an 8-bit 2's-complement number → −1.

The bits are identical. The interpretation rule changes the meaning.

Let's Clarify

A bit pattern works like a written symbol whose meaning depends on context. The sequence 11111111 is not inherently 255 or −1. If the system treats it as unsigned binary, it is 255. If the same eight bits are interpreted using 2's-complement signed rules, the value is −1.

Common Mistake

Seeing an MSB of 1 does not automatically make every binary number negative. The MSB acts as a sign indicator only when the data is explicitly being interpreted under a signed representation such as sign-magnitude, 1's complement, or 2's complement.

Summary

  • Signed binary representation allows fixed-width bit patterns to encode positive and negative integers.
  • Sign-magnitude stores a separate sign bit and an unsigned magnitude.
  • 1's complement forms negative values by inverting every positive-value bit.
  • 2's complement forms negative values by inversion followed by adding 1.
  • 2's complement has one zero and an n-bit range from −2n−1 to 2n−1−1.
  • The same bit pattern can have different values under signed and unsigned interpretations.

Test Yourself

  1. Represent +18 and −18 in 8-bit sign-magnitude, 1's complement, and 2's complement.
  2. What is the range of an 8-bit 2's-complement integer?
  3. Interpret 11110101 as an 8-bit 2's-complement value.

Hints:

  1. +18 = 00010010 in all three. Sign-magnitude −18 = 10010010; 1's complement = 11101101; 2's complement = 11101110.
  2. −27 to 27−1 = −128 to +127.
  3. Invert → 00001010; add 1 → 00001011 = 11. Therefore the original value is −11.

Exam Questions

  1. List out the major characteristics of IC. (Model Q)
  2. What is BCD code? (2024)
  3. Convert (1010)₂ to gray code. (2024)
  4. Convert (101011.1101)₂ to Octal and Hexadecimal form. (2024)
  5. Find the value of (279)₁₀ + (799)₁₀ by converting it to BCD data. (2024)
  6. What is digital system? (April, 2023)
  7. How many different combination can be represented by 5-bit binary data? (April, 2023)
  8. Convert 2A3B.2A₁₆ into binary, octal and decimal. (April, 2023)
  9. What is gray code? (April, 2023)
  10. Define Digital System. (October, 2023)
  11. Convert gray code: 1011 to binary. (October, 2023)
  12. Convert (2A31)₁₆ into decimal, binary and octal form. (October, 2023)
  13. Compute (-20)₁₀ + (+30)₁₀, using 2's complement method. (October, 2023)

Whole Chapter Summary

Digital Versus Analog Signals

Analog signals vary continuously, while digital signals represent information using discrete states. Binary digital systems normally use logic 0 and logic 1, represented by valid electrical ranges rather than ideal mathematical points.

Digital Integrated Circuits

Digital ICs combine many electronic components on one semiconductor chip. Their behavior is described by characteristics such as propagation delay, fan-in, fan-out, power dissipation, and noise margin, while integration levels progress from SSI toward VLSI and ULSI.

Digital Systems and Applications

A digital system receives, represents, processes, stores, and outputs discrete information. Digital systems form the basis of computers, communication devices, industrial control, consumer electronics, instrumentation, transportation, and many other technologies.

Digital Codes and Conversions

Digital codes assign meanings to binary patterns. Different codes are designed for numerical digits, characters, or special transition properties, so conversion rules are required whenever information changes representation.

Decimal, Binary, Octal, and Hexadecimal

These positional systems use bases 10, 2, 8, and 16. Binary is fundamental to digital hardware, while octal and hexadecimal provide compact representations because their digits map directly to groups of three and four binary bits.

Number-System Conversion

Base-to-decimal conversion uses positional expansion. Decimal integers use repeated division, fractions use repeated multiplication, and direct binary grouping provides efficient conversion to and from octal and hexadecimal.

Binary-Coded Decimal

BCD stores each decimal digit in a separate 4-bit 8421 group. In BCD addition, results above 1001 or groups producing a carry require addition of 0110 to obtain a valid decimal-digit representation.

Excess-3

Excess-3 encodes each decimal digit after adding 3. It is non-weighted and self-complementing, so bitwise complementation produces the code for the decimal digit's 9's complement.

Gray Code

Gray code arranges consecutive values so only one bit changes at a time. Binary-to-Gray uses XOR between adjacent binary bits, while Gray-to-binary uses cumulative XOR based on the preceding binary result.

Alphanumeric Codes

Alphanumeric encodings allow letters, digits, punctuation, and control symbols to be stored as binary values. ASCII is fundamentally 7-bit, while EBCDIC is an 8-bit character code historically used in IBM-oriented systems.

Binary Addition and Subtraction

Binary arithmetic applies base-2 carry and borrow rules. Since 1 + 1 equals binary 10, addition creates a carry quickly, while subtraction from 0 requires borrowing binary 10 from the next higher position.

1's and 2's Complements

1's complement inverts every bit, while 2's complement additionally adds 1. Complement arithmetic converts subtraction into addition, and 2's complement provides a single zero representation suitable for fixed-width signed arithmetic.

Signed Number Representation

Sign-magnitude, 1's complement, and 2's complement provide different methods for encoding negative integers. 2's complement gives one zero and an n-bit range from −2n−1 to 2n−1−1.

Key Formulas and Points Sheet

Formula or RuleMeaning
N = Σ diriGeneral positional number-system expansion using base r.
Number of n-bit patterns = 2nEach of n bits has two possible values.
Unsigned n-bit range = 0 to 2n−1Range when all bit patterns represent non-negative values.
1 octal digit = 3 binary bitsBecause 8 = 23.
1 hexadecimal digit = 4 binary bitsBecause 16 = 24.
BCD correction = add 0110Apply when a BCD digit sum exceeds 1001 or creates a carry.
Excess-3 code = binary(decimal digit + 3)Rule for encoding one decimal digit in Excess-3.
Binary → Gray: first Gray bit = first binary bitCopy the MSB directly.
Remaining Gray bit = adjacent binary bits XORUse previous binary bit XOR current binary bit.
Gray → binary: first binary bit = first Gray bitCopy the MSB directly.
Remaining binary bit = previous binary result XOR current Gray bitCumulative rule for decoding Gray code.
1's complement = invert every bit0 becomes 1 and 1 becomes 0.
2's complement = 1's complement + 1Standard method for forming a negative 2's-complement value.
Sign-magnitude range = −(2n−1−1) to +(2n−1−1)One sign bit and n−1 magnitude bits; two representations of zero.
1's-complement range = −(2n−1−1) to +(2n−1−1)Two representations of zero.
2's-complement range = −2n−1 to +(2n−1−1)One zero and one additional negative value.
Standard ASCII patterns = 27 = 128Standard ASCII uses seven bits.
EBCDIC patterns = 28 = 256EBCDIC uses eight-bit code values.

Last-Minute Revision Sheet

ConceptTrigger PhraseRecall Cue
Analog signalContinuous valuesAny value inside a range
Digital signalDiscrete statesUsually logic 0 and 1
Digital ICMany circuits on one chipCompact + reliable + fast
Fan-inInputs of a gateHow many inputs enter
Fan-outOutput loadingHow many inputs one output drives
Propagation delayResponse timeInput change → output change
Integration levelsIncreasing circuit densitySSI → MSI → LSI → VLSI → ULSI
Digital systemDiscrete data processingInput → process/store → output
BinaryBase 20, 1
OctalBase 83 binary bits per digit
HexadecimalBase 164 binary bits per digit
n binary bitsPossible combinations2n
Base → decimalPlace valuesDigit × baseposition
Decimal integer → baseRepeated divisionRemainders read upward
Decimal fraction → baseRepeated multiplicationInteger parts read downward
BCDEach decimal digit separately4-bit 8421 groups
BCD correctionInvalid digit or carryAdd 0110
Excess-3Digit + 3Non-weighted, self-complementing
Gray codeOne-bit transitionAdjacent values differ by one bit
Binary → GrayAdjacent XORCopy MSB, then Bprevious XOR Bcurrent
Gray → binaryCumulative XORPrevious binary result XOR current Gray bit
ASCII7-bit character code128 standard codes
EBCDIC8-bit character codeHistorically IBM-oriented
Binary addition1 + 110: write 0, carry 1
Binary subtraction0 − 1Borrow → current value becomes 102
1's complementInvert0 ↔ 1
2's complementInvert + 1Standard signed arithmetic form
Sign-magnitudeSeparate sign bitMSB sign + remaining magnitude
2's-complement rangeAsymmetric signed range−2n−1 to 2n−1−1
Negative 2's complementDecode magnitudeInvert + 1, then attach negative sign
Views: …
TUpapers.com logo tupapers.com
  • Privacy Policy

  • Contact Us

  • Terms

  • Pricing

  • SEEpapers.com

TUpapers on Facebook
TUpapers on Instagram
Contact TUpapers on WhatsApp Contact TUpapers on WhatsApp
TUpapers subreddit on Reddit

Courses

  • BBA

  • BCA

  • BIT

  • CSIT

  • BBS

  • BHM

  • BBM

  • BITM

  • BTTM

  • BA

  • BE

  • BSW

© 2026 tupapers.com. All rights reserved.