Unit 1: Binary Systems [6 Hours]
Binary systems form the numerical and logical foundation of digital computers and electronic systems. This unit explains how digital systems represent information using two states, how numbers are written and converted among binary, octal, decimal, and hexadecimal bases, and how complements and signed representations support arithmetic. It also covers decimal codes such as Binary-Coded Decimal, weighted codes, Excess-3 and Gray code, followed by binary storage, registers, and the basic logic operations used to process binary information.
Tested Topics
- Gray Code — 2x (2083, 2081)
- Number base conversion — 2x (2083, 2081)
- BCD — 1x (2081)
- Binary addition — 1x (2078)
- Complement arithmetic — 1x (2080)
- Digital and analog systems — 1x (2078)
1.1 Digital Systems
Definition
A digital system is a system that represents, processes, stores, or transmits information using a finite set of discrete values, usually the binary values 0 and 1.
A digital system works with clearly separated states. A switch can be OFF or ON, a stored bit can be 0 or 1, and a logic circuit can treat a voltage range as LOW or HIGH. Instead of following every possible value continuously, the system works with selected discrete levels.
Detailed Explanation
The word digital comes from the idea of representing information using distinct symbols or digits. Modern digital electronics normally uses the binary number system, where only two symbols, 0 and 1, are required.
A digital system normally performs one or more of the following functions:
- Input: receives information from a keyboard, sensor, switch, network, or another system.
- Processing: performs arithmetic, comparison, logical decisions, encoding, or other operations.
- Storage: keeps binary information in memory cells, registers, disks, or other storage devices.
- Output: presents or transmits the processed information.
For example, when a student enters the number 25 into a calculator, the calculator converts the input into an internal binary representation, performs operations using digital circuits, stores temporary results, and converts the final result into a form that can be displayed.
Discrete Values
A discrete value is a separate and distinct value rather than a continuously changing one. A digital signal therefore changes among defined levels.
In a typical binary digital system:
- Logic 0 represents one state, often called LOW, FALSE, OFF, or inactive.
- Logic 1 represents the other state, often called HIGH, TRUE, ON, or active.
The exact electrical voltage corresponding to 0 or 1 depends on the electronic technology being used. The logical meaning is more important than the exact voltage value.
Analog Systems
An analog system represents information using continuously varying physical quantities. Its value can change smoothly through an entire range rather than moving between fixed digital levels.
Examples include:
- the continuously changing voltage produced by an analog microphone,
- the position of the pointer in a traditional analog voltmeter,
- the continuous motion of the hands of a mechanical clock,
- physical quantities such as temperature, pressure, speed, and sound pressure.
If temperature changes from 20°C to 21°C, the real physical temperature can pass through 20.1°C, 20.25°C, 20.753°C, and infinitely many values in between. This continuous behavior is characteristic of analog information.
Let's Clarify
A traditional water tap provides a useful comparison. Its water flow can be adjusted continuously from almost zero to maximum, which resembles an analog quantity. A normal wall switch has distinct OFF and ON positions, which resembles a digital quantity. Digital systems gain reliability because they distinguish defined states instead of depending on every tiny variation in a continuously changing value.
Digital System and Analog System Compared
| Basis | Digital System | Analog System |
|---|---|---|
| Representation | Uses discrete values. | Uses continuous values. |
| Typical signal | Distinct LOW and HIGH levels. | Continuously varying signal. |
| Internal representation | Usually binary 0 and 1. | Physical quantity varies continuously. |
| Noise resistance | Generally more resistant because ranges can represent logical states. | Small unwanted variations directly affect the represented quantity. |
| Storage | Binary data can be copied and stored accurately. | Exact storage and reproduction of a continuous signal is more difficult. |
| Processing | Performed using arithmetic and logic circuits. | Performed using continuously varying electrical or physical quantities. |
| Examples | Digital computer, smartphone, digital calculator. | Traditional analog meter, analog measuring instruments. |
Digital Computer and Analog Computer
A digital computer processes information represented by discrete binary digits. General-purpose computers, laptops, smartphones, and most modern computing systems are digital computers.
An analog computer represents and solves problems by using continuously varying physical quantities such as voltage, current, rotation, or fluid motion to model another physical system.
| Basis | Digital Computer | Analog Computer |
|---|---|---|
| Data | Processes discrete numerical and symbolic data. | Processes continuous physical quantities. |
| Representation | Normally binary digits 0 and 1. | Continuously changing measurable values. |
| Precision | Depends mainly on number of bits and computational method. | Depends strongly on component accuracy and measurement precision. |
| Storage | Large amounts of data can be stored digitally. | Continuous values are not as convenient to store exactly. |
| Programming | General-purpose digital machines can execute many programs. | Often configured to model a particular physical problem. |
| Typical use | Business, education, communication, scientific computing, software systems. | Continuous-system simulation, measurement, and specialized control applications. |
Why Digital Representation Is Widely Used
- Reliable distinction between states: small signal variations often do not change whether a value is interpreted as 0 or 1.
- Easy storage: binary information can be stored in memory elements having two stable states.
- Easy processing: arithmetic and decision operations can be implemented using logic circuits.
- Reproducibility: digital data can be copied without gradually accumulating the same type of degradation associated with repeated analog copying.
- Programmability: the same hardware can perform different tasks under program control.
Common Mistake
Digital does not mean that a physical signal contains mathematically perfect zero volts and one fixed nonzero voltage. Actual electronic signals are physical and may vary. A digital circuit interprets ranges of physical values as distinct logical states.
Summary
- A digital system represents information with discrete states, commonly binary 0 and 1.
- An analog system represents information with continuously varying quantities.
- Digital systems are well suited to storage, logic processing, copying, and programmable computation.
- A digital computer works on discrete binary data, while an analog computer models quantities using continuous physical values.
- LOW/HIGH, OFF/ON, and FALSE/TRUE are common interpretations of binary logical states.
Test Yourself
- What is a digital system, and how does it differ from an analog system?
- Differentiate analog computer with digital computer. (2078)
Hints:
- Digital systems use discrete states, normally 0 and 1. Analog systems use continuously varying values. Compare representation, signal form, storage, processing, and noise behavior.
- Digital computer: discrete binary data, programmable processing, convenient storage. Analog computer: continuously varying physical quantities, continuous modeling, accuracy dependent on physical components and measurement.
1.2 Binary Numbers
Definition
A binary number is a number written in the base-2 number system using only the digits 0 and 1.
Decimal numbers use ten digits from 0 to 9. Binary needs only two. Each position represents a power of 2, so the position of a 1 tells us which power of 2 contributes to the total value.
Detailed Explanation
The binary number system is the natural numerical system for digital hardware because electronic circuits can represent two logical states efficiently.
Each binary digit is called a bit, short for binary digit. A sequence such as 101101 contains six bits.
Positional Value in Binary
Binary is a positional number system. Starting from the right side of the binary point, the place values are powers of 2:
... 25, 24, 23, 22, 21, 20 . 2-1, 2-2, 2-3 ...
For example:
(101101)2
= 1 × 25 + 0 × 24 + 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20
= 32 + 0 + 8 + 4 + 0 + 1
= (45)10
Binary Fractions
Positions to the right of the binary point use negative powers of 2.
For example:
(0.101)2
= 1 × 2-1 + 0 × 2-2 + 1 × 2-3
= 1/2 + 0/4 + 1/8
= 0.5 + 0.125
= (0.625)10
Common Binary Groupings
- 1 bit: one binary digit.
- 4 bits: one nibble.
- 8 bits: one byte.
- Word: a processor-related group of bits treated as one unit. Word size depends on the computer architecture.
Binary Addition
Binary addition follows the same column-by-column idea as decimal addition, but every digit is either 0 or 1.
The basic addition rules are:
| Operation | Sum Bit | Carry |
|---|---|---|
| 0 + 0 | 0 | 0 |
| 0 + 1 | 1 | 0 |
| 1 + 0 | 1 | 0 |
| 1 + 1 | 0 | 1 |
| 1 + 1 + 1 | 1 | 1 |
The rule 1 + 1 = 102 means the current column receives 0 and a carry of 1 is transferred to the next higher position.
Worked Example: Binary Addition
Add (11001)2 and (11011)2.
1 1 0 0 1
+ 1 1 0 1 1
-----------
1 1 0 1 0 0Working from right to left:
- 1 + 1 = 10 → write 0, carry 1.
- 0 + 1 + carry 1 = 10 → write 0, carry 1.
- 0 + 0 + carry 1 = 1 → write 1, no carry.
- 1 + 1 = 10 → write 0, carry 1.
- 1 + 1 + carry 1 = 11 → write 1, carry 1.
- Write the remaining carry 1.
Therefore:
(11001)2 + (11011)2 = (110100)2
A decimal check confirms the result:
25 + 27 = 52, and (52)10 = (110100)2.
Basic Binary Subtraction Rules
| Operation | Result |
|---|---|
| 0 − 0 | 0 |
| 1 − 0 | 1 |
| 1 − 1 | 0 |
| 0 − 1 | Borrow from the next position: 102 − 1 = 1 |
Direct subtraction is possible, but digital systems commonly use complement methods because subtraction can then be performed by an addition circuit. That method is developed in 1.5 Complements.
Let's Clarify
In decimal arithmetic, reaching 10 in one column produces a carry because ten is the base. Binary has base 2, so reaching 2 produces a carry. That is why 1 + 1 does not become a new single binary digit; it becomes 102.
Common Mistake
The binary expression 102 is not decimal ten. It represents decimal two. The written digits look the same as decimal 10, but their value depends on the base.
Summary
- Binary is a base-2 positional number system containing only 0 and 1.
- Each binary digit is a bit, and each position carries a power-of-2 weight.
- Positions right of the binary point represent negative powers of 2.
- Binary addition uses the key carry rule 1 + 1 = 102.
- Binary subtraction can use direct borrowing or complement-based arithmetic.
Test Yourself
- Find the decimal value of (101101.01)2.
- Why does 1 + 1 produce 10 in binary?
- How binary addition is done? Show binary addition of (11001) with (11011). (2078)
Hints:
- Use powers 25 to 20 and fractional powers 2-1, 2-2. Result: 45.25.
- Binary has base 2. A column that totals 2 writes 0 and carries 1 to the next position.
- Use 0+0=0, 0+1=1, 1+1=10 and carry column by column. Result: (110100)2.
1.3 Number Base Conversion
Definition
Number base conversion is the process of changing the representation of a number from one number system to another without changing its actual value.
The written form changes, but the quantity does not. Decimal 10, binary 1010, octal 12, and hexadecimal A are different representations of the same numerical value.
Detailed Explanation
A radix or base tells how many distinct digit symbols are used by a positional number system. The common bases in digital systems are:
| Number System | Base | Allowed Digits |
|---|---|---|
| Binary | 2 | 0, 1 |
| Octal | 8 | 0 to 7 |
| Decimal | 10 | 0 to 9 |
| Hexadecimal | 16 | 0 to 9, A to F |

General Positional Value Formula
For a number written in base r:
(dndn-1...d1d0.d-1d-2...)r
its decimal value is:
dnrn + dn-1rn-1 + ... + d1r1 + d0r0 + d-1r-1 + d-2r-2 + ...
Each digit is multiplied by the positional weight associated with its position.
Conversion from Any Base to Decimal
To convert a positional number from base r to decimal:
- Write the power of the base associated with every position.
- Multiply each digit by its positional weight.
- Add all products.
Worked Example: Hexadecimal to Decimal
Convert (F4B.B)16 to decimal.
In hexadecimal:
- F = 15
- B = 11
Therefore:
(F4B.B)16
= 15 × 162 + 4 × 161 + 11 × 160 + 11 × 16-1
= 15 × 256 + 4 × 16 + 11 × 1 + 11/16
= 3840 + 64 + 11 + 0.6875
= (3915.6875)10
Decimal Integer to Another Base
To convert a decimal integer to base r, use repeated division by r.
- Divide the decimal integer by the target base.
- Record the remainder.
- Divide the quotient again by the target base.
- Continue until the quotient becomes 0.
- Read the remainders from bottom to top.
Worked Example: Decimal 110 to Binary
| Division | Quotient | Remainder |
|---|---|---|
| 110 ÷ 2 | 55 | 0 |
| 55 ÷ 2 | 27 | 1 |
| 27 ÷ 2 | 13 | 1 |
| 13 ÷ 2 | 6 | 1 |
| 6 ÷ 2 | 3 | 0 |
| 3 ÷ 2 | 1 | 1 |
| 1 ÷ 2 | 0 | 1 |
Reading the remainders upward:
(110)10 = (1101110)2
Decimal Fraction to Another Base
To convert a decimal fraction to base r, use repeated multiplication by r.
- Multiply the fractional part by the target base.
- Record the integer part of the result.
- Take the new fractional part and multiply it again by the target base.
- Continue until the fractional part becomes zero or the required precision is reached.
- Read the recorded integer parts from top to bottom.
Worked Example: Decimal 0.625 to Binary
| Multiplication | Integer Part | Fractional Part |
|---|---|---|
| 0.625 × 2 = 1.25 | 1 | 0.25 |
| 0.25 × 2 = 0.5 | 0 | 0.5 |
| 0.5 × 2 = 1.0 | 1 | 0 |
Reading the integer parts downward:
(0.625)10 = (0.101)2
Combining the integer and fraction:
(110.625)10 = (1101110.101)2
Worked Example: Decimal 110.625 to Octal
For the integer part:
| Division | Quotient | Remainder |
|---|---|---|
| 110 ÷ 8 | 13 | 6 |
| 13 ÷ 8 | 1 | 5 |
| 1 ÷ 8 | 0 | 1 |
Thus:
(110)10 = (156)8
For the fraction:
0.625 × 8 = 5.0
Therefore:
(0.625)10 = (0.5)8
Hence:
(110.625)10 = (156.5)8
Binary to Octal Conversion
Since 8 = 23, one octal digit corresponds exactly to three binary bits.
Procedure:
- Starting from the binary point, divide binary digits into groups of three.
- For the integer portion, group toward the left.
- For the fractional portion, group toward the right.
- Add leading or trailing zeros when a group is incomplete.
- Replace each three-bit group with the corresponding octal digit.
Example:
(110001)2
= 110 001
= 6 1
= (61)8
Octal to Binary Conversion
Replace each octal digit with its three-bit binary equivalent.
Example:
(572)8
5 → 101
7 → 111
2 → 010
Therefore:
(572)8 = (101111010)2
Binary to Hexadecimal Conversion
Since 16 = 24, one hexadecimal digit corresponds to four binary bits.
Example:
(1011011110)2
Pad and group:
0010 1101 1110
0010 = 2
1101 = D
1110 = E
Therefore:
(1011011110)2 = (2DE)16
Hexadecimal to Binary Conversion
Replace every hexadecimal digit with four binary bits.
Convert (A57)16 to binary:
A → 1010
5 → 0101
7 → 0111
Therefore:
(A57)16 = (101001010111)2
Octal and Hexadecimal Conversion Through Binary
Because both octal and hexadecimal have direct power-of-two relationships with binary, conversion between them is conveniently performed through binary.
Octal → Binary → Hexadecimal
or
Hexadecimal → Binary → Octal
Example:
(73)8
7 → 111
3 → 011
Thus:
(73)8 = (111011)2
Group into four bits:
0011 1011
0011 = 3
1011 = B
Therefore:
(73)8 = (3B)16
Let's Clarify
Repeated division and repeated multiplication perform opposite jobs. For a decimal integer, division exposes digits from the least significant position upward, so the remainders are read in reverse order. For a decimal fraction, multiplication exposes digits starting immediately after the radix point, so the integer parts are read in the order produced.
Common Mistake
In repeated division, remainders are read bottom to top. In repeated multiplication, the extracted integer parts are read top to bottom. Reversing either order produces the wrong representation.
Summary
- Base conversion changes representation without changing numerical value.
- Any positional number can be converted to decimal by multiplying digits by powers of its base.
- Decimal integers use repeated division by the target base; decimal fractions use repeated multiplication.
- Binary and octal convert directly in groups of three bits.
- Binary and hexadecimal convert directly in groups of four bits.
- Octal and hexadecimal can be converted efficiently through binary.
Test Yourself
- Convert (725.4)8 to decimal.
- Convert (93.375)10 to binary.
- Convert the following as indicated:
a) (F4B.B)16 to Decimal
b) (110.625)10 to Binary and Octal (2083) - Perform the following conversion
a) (A57)₁₆ to binary
b) (110001)₂ to octal (2.5+2.5) (2081)
Hints:
- 7×82 + 2×8 + 5 + 4×8-1 = 469.5.
- 93 = 10111012; 0.375 = 0.0112. Result: 1011101.0112.
- a) Expand each hexadecimal digit by powers of 16: 3915.687510. b) Integer 110 gives 11011102, fraction .625 gives .1012; octal result is 156.58.
- a) A=1010, 5=0101, 7=0111 → 1010010101112. b) Group 110 001 → 6 1 → 618.
1.4 Octal and Hexadecimal Numbers
Definition
An octal number is a base-8 number using digits 0 to 7, while a hexadecimal number is a base-16 number using digits 0 to 9 and letters A to F.
Binary strings can become long and difficult to read. Octal compresses every three binary bits into one digit, while hexadecimal compresses every four binary bits into one digit.
Detailed Explanation
Octal Number System
The octal number system has radix 8 and therefore uses eight symbols:
0, 1, 2, 3, 4, 5, 6, 7
Its positional weights are powers of 8:
... 83, 82, 81, 80 . 8-1, 8-2 ...
Example:
(357)8
= 3 × 82 + 5 × 81 + 7 × 80
= 192 + 40 + 7
= (239)10
Octal-to-Binary Relationship
| Octal | Binary |
|---|---|
| 0 | 000 |
| 1 | 001 |
| 2 | 010 |
| 3 | 011 |
| 4 | 100 |
| 5 | 101 |
| 6 | 110 |
| 7 | 111 |
This direct relationship follows from 8 = 23.
Hexadecimal Number System
The hexadecimal number system has radix 16. It requires sixteen symbols:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
The letters represent decimal values:
- A = 10
- B = 11
- C = 12
- D = 13
- E = 14
- F = 15
Its positional weights are powers of 16:
... 163, 162, 161, 160 . 16-1, 16-2 ...
Example:
(2AF)16
= 2 × 162 + 10 × 16 + 15
= 512 + 160 + 15
= (687)10
Hexadecimal-to-Binary Relationship
| Hexadecimal | Binary |
|---|---|
| 0 | 0000 |
| 1 | 0001 |
| 2 | 0010 |
| 3 | 0011 |
| 4 | 0100 |
| 5 | 0101 |
| 6 | 0110 |
| 7 | 0111 |
| 8 | 1000 |
| 9 | 1001 |
| A | 1010 |
| B | 1011 |
| C | 1100 |
| D | 1101 |
| E | 1110 |
| F | 1111 |
The four-bit relationship follows from 16 = 24.
Octal and Hexadecimal Compared
| Property | Octal | Hexadecimal |
|---|---|---|
| Base | 8 | 16 |
| Symbols | 0–7 | 0–9, A–F |
| Binary bits per digit | 3 | 4 |
| Largest single-digit value | 7 | F = 15 |
| Compression of binary | Moderate | Greater than octal for the same binary pattern |
Why Octal and Hexadecimal Are Useful
Computers internally work with binary, but humans can make mistakes when reading long binary strings. Octal and hexadecimal provide compact representations while preserving an easy conversion path back to binary.
For example:
Binary: 1111011010111100
In hexadecimal:
1111 0110 1011 1100 → F 6 B C
So:
(1111011010111100)2 = (F6BC)16
Common Mistake
The digit 8 is invalid in octal, and symbols beyond F are invalid in standard hexadecimal notation. A number such as (128)8 is therefore not a valid octal numeral.
Summary
- Octal is base 8 and uses digits 0 through 7.
- Hexadecimal is base 16 and uses 0–9 and A–F.
- One octal digit corresponds to three binary bits.
- One hexadecimal digit corresponds to four binary bits.
- Both systems provide shorter, more readable representations of binary values.
Test Yourself
- Why can every octal digit be replaced by exactly three binary bits?
- Convert (7D3)16 to binary and (101111001)2 to octal.
- What is the decimal value of (3A7)16?
Hints:
- Because 8 = 23; three bits can represent 000 through 111, equivalent to decimal 0 through 7.
- 7D3 → 0111 1101 0011. Binary 101 111 001 → 5718.
- 3×256 + 10×16 + 7 = 935.
1.5 Complements
Definition
A complement is an alternative representation of a number used mainly to perform subtraction through addition and to represent negative values in digital systems.
Instead of building a separate arithmetic process for every subtraction, a system can transform the number being subtracted into a complement and add it. Binary systems commonly use 1's complement and 2's complement, while decimal complement arithmetic uses 9's complement and 10's complement.
Detailed Explanation
For a number system of radix r, two general complements are used:
- (r − 1)'s complement: also called the diminished radix complement.
- r's complement: also called the radix complement.
Diminished Radix Complement
For an n-digit number N in base r:
(r − 1)'s complement = (rn − 1) − N
For binary, r = 2, so the diminished radix complement is 1's complement.
For decimal, r = 10, so the diminished radix complement is 9's complement.
Radix Complement
For an n-digit number N:
r's complement = rn − N
It can also be found by:
r's complement = (r − 1)'s complement + 1
Thus:
- 2's complement = 1's complement + 1
- 10's complement = 9's complement + 1
1's Complement
The 1's complement of a binary number is obtained by changing every 0 to 1 and every 1 to 0.
Example:
Original number: 101001
1's complement: 010110
2's Complement
The 2's complement of a binary number is obtained by taking its 1's complement and adding 1.
Example:
Number: 101001
1's complement: 010110
Add 1:
010110
+ 1
------
010111Therefore the 2's complement of 101001 is 010111.
9's Complement
The 9's complement of a decimal number is obtained by subtracting every digit from 9.
Example:
Number: 58324
9's complement:
- 9 − 5 = 4
- 9 − 8 = 1
- 9 − 3 = 6
- 9 − 2 = 7
- 9 − 4 = 5
Therefore:
9's complement of 58324 = 41675
10's Complement
The 10's complement is found by adding 1 to the 9's complement.
For 58324:
9's complement = 41675
10's complement = 41675 + 1 = 41676
General Complement Comparison
| Base | Diminished Radix Complement | Radix Complement |
|---|---|---|
| Binary, base 2 | 1's complement | 2's complement |
| Decimal, base 10 | 9's complement | 10's complement |
Subtraction Using 2's Complement
To calculate M − N using 2's complement:
- Use the same number of bits for M and N.
- Find the 2's complement of N.
- Add this complement to M.
- If an end carry appears, discard the carry. The remaining result is positive.
- If no end carry appears, the result is negative. Find the 2's complement of the obtained sum to find its magnitude and attach a minus sign.

Worked Example: (011101)2 − (110011)2 Using 2's Complement
Let:
M = 011101
N = 110011
First find the 2's complement of N.
1's complement of 110011:
001100
Add 1:
001100 + 1 = 001101
Now add it to M:
011101
+ 001101
--------
101010There is no end carry, so the result is negative.
Find the 2's complement of 101010 to obtain the magnitude:
1's complement:
010101
Add 1:
010101 + 1 = 010110
Therefore:
(011101)2 − (110011)2 = −(010110)2
In six-bit 2's complement representation, the stored result is 101010. Its decimal value is −22.
Subtraction Using 1's Complement
To compute M − N using 1's complement:
- Find the 1's complement of N.
- Add it to M.
- If a carry is produced, add that carry back to the least significant bit. This is called an end-around carry.
- If no carry is produced, complement the result and mark it negative.
Example: calculate 10110 − 01101.
1's complement of 01101 = 10010.
10110
+ 10010
-------
1 01000Add the end-around carry:
01000
+ 1
-----
01001Therefore:
10110 − 01101 = 01001
Decimal check: 22 − 13 = 9.
Subtraction Using 9's Complement
For decimal subtraction M − N using 9's complement:
- Use the same number of decimal digits in both numbers.
- Find the 9's complement of N.
- Add it to M.
- If an end carry appears, add it to the least significant digit.
- If no end carry appears, take the 9's complement of the sum and attach a minus sign.
Worked Example: 89344 − 98654 Using 9's Complement
Find the 9's complement of 98654:
9 − 9 = 0
9 − 8 = 1
9 − 6 = 3
9 − 5 = 4
9 − 4 = 5
Therefore:
9's complement of 98654 = 01345
Add it to 89344:
89344
+ 01345
-------
90689No end carry is produced, so the answer is negative.
Find the 9's complement of 90689:
9's complement of 90689 = 09310
Therefore:
89344 − 98654 = −9310
Subtraction Using 10's Complement
For M − N using 10's complement:
- Find the 10's complement of N.
- Add it to M.
- If there is an end carry, discard the carry and keep the remaining digits.
- If there is no end carry, find the 10's complement of the sum and attach a negative sign.
1's versus 2's Complement
| Property | 1's Complement | 2's Complement |
|---|---|---|
| Formation | Invert every bit. | Invert every bit and add 1. |
| Zero representations | Two: positive zero and negative zero. | One zero representation. |
| Subtraction carry handling | End-around carry is added back. | End carry is discarded. |
| Signed-number use | Possible but less convenient. | Widely used for signed integer representation. |
Let's Clarify
Complement subtraction changes the problem from M − N into a form of M + complement(N). This matters in hardware because an adder circuit can then participate in both addition and subtraction rather than requiring completely independent arithmetic hardware for the two operations.
Common Mistake
The carry rules for 1's and 2's complement subtraction are different. In 1's complement, an end carry is added back to the least significant position. In 2's complement, an end carry is discarded.
Summary
- Complements convert subtraction into an addition-based procedure.
- 1's complement is formed by bit inversion; 2's complement is 1's complement plus 1.
- 9's complement subtracts each decimal digit from 9; 10's complement adds 1 to the 9's complement.
- 1's and 9's complement methods use end-around carry when a carry occurs.
- 2's and 10's complement methods discard an end carry.
- No carry in complement subtraction indicates a negative result whose magnitude must be recovered by complementing the sum.
Test Yourself
- Find the 1's and 2's complements of 10110010.
- Explain the difference between subtraction using 1's complement and 2's complement.
- Perform the following operations:
a. (011101)2-(110011)2 using 2's complement
b. (89344)10-(98654)10 using 9's complement (2080)
Hints:
- 1's complement = 01001101. Add 1 to obtain 2's complement = 01001110.
- 1's complement uses bit inversion and end-around carry; 2's complement uses inversion plus 1 and discards an end carry.
- a) 2's complement of 110011 is 001101; sum = 101010 with no carry → result −0101102. b) 9's complement of 98654 is 01345; sum = 90689 with no carry → complement gives 09310 → −9310.
1.6 Signed Binary Numbers
Definition
A signed binary number is a binary representation that includes information about whether the represented number is positive or negative.
Ordinary unsigned binary bits represent only non-negative values. To represent values below zero, computers use a defined encoding method such as sign-magnitude, 1's complement, or 2's complement.
Detailed Explanation
An n-bit unsigned binary number can represent values from:
0 to 2n − 1
For example, an 8-bit unsigned number represents values from:
0 to 28 − 1 = 255
Signed representations reserve part of the bit pattern to distinguish negative values from positive values.
Sign-Magnitude Representation
In sign-magnitude representation, the most significant bit acts as a sign bit:
- 0 indicates a positive number.
- 1 indicates a negative number.
The remaining bits store the magnitude.
Using 8 bits:
+13:
00001101
−13:
10001101
The major weakness is that zero has two representations:
+0 = 00000000
−0 = 10000000
1's Complement Representation
In 1's complement signed representation, a positive number is written normally, while the negative form is obtained by inverting every bit of its positive form.
For 8-bit 13:
+13 = 00001101
Invert every bit:
−13 = 11110010
1's complement also has two representations of zero:
+0 = 00000000
−0 = 11111111
2's Complement Representation
In 2's complement signed representation, a negative value is produced by taking the 1's complement of its positive magnitude and adding 1.
For 8-bit 13:
+13 = 00001101
1's complement = 11110010
Add 1:
−13 = 11110011
Unlike sign-magnitude and 1's complement, 2's complement has only one representation of zero.
Ranges of Signed Representations
For n bits:
| Representation | Minimum Value | Maximum Value | Zero Representations |
|---|---|---|---|
| Sign-Magnitude | −(2n−1 − 1) | +(2n−1 − 1) | 2 |
| 1's Complement | −(2n−1 − 1) | +(2n−1 − 1) | 2 |
| 2's Complement | −2n−1 | +(2n−1 − 1) | 1 |
For 8 bits:
- Sign-magnitude: −127 to +127.
- 1's complement: −127 to +127.
- 2's complement: −128 to +127.
Finding the Decimal Value of a Negative 2's Complement Number
If the most significant bit of a fixed-width 2's complement number is 1, the number is negative.
Example: interpret 11110101 as an 8-bit 2's complement number.
- Invert every bit: 00001010.
- Add 1: 00001011.
- 00001011 = 11 decimal.
- Therefore the original number is −11.
Alternative Positional Interpretation of 2's Complement
In an n-bit 2's complement number, the most significant bit has weight −2n−1. All other bits retain positive binary weights.
For 8-bit 11110101:
= −128 + 64 + 32 + 16 + 0 + 4 + 0 + 1
= −11
Sign-Magnitude, 1's Complement, and 2's Complement Compared
| Feature | Sign-Magnitude | 1's Complement | 2's Complement |
|---|---|---|---|
| Negative formation | Change sign bit to 1. | Invert all bits. | Invert all bits and add 1. |
| Positive form | Normal binary with sign bit 0. | Normal binary with leading 0. | Normal binary with leading 0. |
| Number of zeros | Two | Two | One |
| Negative range for n bits | −(2n−1−1) | −(2n−1−1) | −2n−1 |
| Arithmetic convenience | Requires special sign handling. | Requires end-around carry in some arithmetic. | Supports convenient addition and subtraction. |
Overflow in Signed Binary Arithmetic
Overflow occurs when the true arithmetic result cannot be represented with the available number of bits.
In 2's complement addition, overflow occurs when:
- two positive numbers produce a result whose sign bit indicates negative, or
- two negative numbers produce a result whose sign bit indicates positive.
Example using 4-bit 2's complement:
0111 represents +7.
0011 represents +3.
0111
+ 0011
------
1010The mathematical result is +10, but 4-bit 2's complement represents only −8 to +7. The bit pattern 1010 would normally mean −6, so the operation has overflowed.
Common Mistake
A leading 1 does not automatically mean a binary number is negative. It indicates negativity only when the bit pattern is explicitly being interpreted under a signed representation such as 2's complement. The same 8-bit pattern 11110101 is 245 when unsigned and −11 when interpreted as 2's complement.
Summary
- Signed binary representation allows both positive and negative values.
- Sign-magnitude uses a dedicated sign bit and stores the remaining magnitude directly.
- 1's complement forms negatives by bit inversion and has two zero representations.
- 2's complement forms negatives by inversion plus 1 and has only one zero.
- An n-bit 2's complement number ranges from −2n−1 to 2n−1−1.
- Overflow occurs when an arithmetic result lies outside the representable range.
Test Yourself
- Represent −25 using 8-bit sign-magnitude, 1's complement, and 2's complement.
- What is the range of an 8-bit 2's complement number?
- Interpret 11101001 as an 8-bit 2's complement number.
Hints:
- +25 = 00011001. Sign-magnitude −25 = 10011001. 1's complement = 11100110. 2's complement = 11100111.
- −27 to 27−1 = −128 to +127.
- Invert → 00010110; add 1 → 00010111 = 23. Therefore the original value is −23.
1.7 Decimal Codes
Definition
A decimal code is a binary coding scheme used to represent decimal digits or decimal information with defined groups of binary bits.
A decimal digit such as 7 can be represented using several different four-bit patterns depending on the code being used. The pattern 0111 means 7 in standard Binary-Coded Decimal, but another coding system may assign a different pattern to the same decimal digit.
Detailed Explanation
Digital circuits operate with binary values, while many human applications use decimal numbers. Decimal codes provide a controlled way to encode decimal digits in binary form.
The codes in this unit include:
- Binary-Coded Decimal (BCD), usually the 8-4-2-1 code,
- 2-4-2-1 code,
- 8-4-−2-−1 code,
- Excess-3 code,
- Gray code.

Weighted and Non-Weighted Codes
A weighted code assigns a fixed numerical weight to every bit position. The represented decimal digit can be determined by adding the weights of bit positions containing 1.
Examples include:
- 8-4-2-1 Binary-Coded Decimal,
- 2-4-2-1 code,
- 8-4-−2-−1 code.
A non-weighted code does not assign fixed positional weights that directly produce the represented value.
Examples include:
- Excess-3 code,
- Gray code.
Binary-Coded Decimal
Binary-Coded Decimal (BCD) is a coding method in which each decimal digit is represented separately by its four-bit binary equivalent.
The most common BCD form is the 8-4-2-1 code. Its bit positions have weights 8, 4, 2, and 1.
| Decimal Digit | 8421 BCD |
|---|---|
| 0 | 0000 |
| 1 | 0001 |
| 2 | 0010 |
| 3 | 0011 |
| 4 | 0100 |
| 5 | 0101 |
| 6 | 0110 |
| 7 | 0111 |
| 8 | 1000 |
| 9 | 1001 |
Only ten of the sixteen possible four-bit combinations are valid BCD digit codes. The combinations 1010 through 1111 do not represent decimal digits in standard 8421 BCD.
Converting Decimal to BCD
Convert each decimal digit separately into its four-bit BCD equivalent.
Example: convert (10)10 to BCD.
Decimal digit 1 → 0001
Decimal digit 0 → 0000
Therefore:
(10)10 = 0001 0000 in BCD
Notice that this is not the same as the ordinary binary representation of decimal 10:
Decimal 10 in pure binary = 1010
Decimal 10 in BCD = 0001 0000
Example: Decimal 59 in BCD
5 → 0101
9 → 1001
Therefore:
(59)10 = 0101 1001 in BCD
BCD Compared with Pure Binary
| Property | BCD | Pure Binary |
|---|---|---|
| Representation method | Each decimal digit encoded separately. | Whole number converted to base 2. |
| Decimal 10 | 0001 0000 | 1010 |
| Bit efficiency | Less efficient. | More compact. |
| Decimal digit conversion | Direct digit-by-digit relation. | Requires base conversion. |
| Typical purpose | Systems where decimal digits must be preserved directly. | General binary computation and storage. |
2-4-2-1 Code
The 2-4-2-1 code is a weighted four-bit decimal code whose bit positions carry weights 2, 4, 2, and 1 from left to right.
A common 2-4-2-1 assignment is:
| Decimal Digit | 2421 Code | Weight Check |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 2 | 0010 | 2 |
| 3 | 0011 | 2 + 1 |
| 4 | 0100 | 4 |
| 5 | 1011 | 2 + 2 + 1 |
| 6 | 1100 | 2 + 4 |
| 7 | 1101 | 2 + 4 + 1 |
| 8 | 1110 | 2 + 4 + 2 |
| 9 | 1111 | 2 + 4 + 2 + 1 |
The 2-4-2-1 code is self-complementing. Complementing all four bits of a valid code word produces the code word for the 9's complement of the corresponding decimal digit.
Example:
2 → 0010
Bit complement → 1101
1101 represents 7, and 9 − 2 = 7.
8-4-−2-−1 Code
The 8-4-−2-−1 code is a weighted decimal code with bit weights 8, 4, −2, and −1.
| Decimal Digit | 84−2−1 Code | Weight Check |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0111 | 4 − 2 − 1 = 1 |
| 2 | 0110 | 4 − 2 = 2 |
| 3 | 0101 | 4 − 1 = 3 |
| 4 | 0100 | 4 |
| 5 | 1011 | 8 − 2 − 1 = 5 |
| 6 | 1010 | 8 − 2 = 6 |
| 7 | 1001 | 8 − 1 = 7 |
| 8 | 1000 | 8 |
| 9 | 1111 | 8 + 4 − 2 − 1 = 9 |
The sum of the positional weights is:
8 + 4 − 2 − 1 = 9
This property allows the code to be self-complementing.
Excess-3 Code
Excess-3 code is a non-weighted decimal code obtained by adding 3 to each decimal digit and then expressing the result as a four-bit binary number.
The encoding rule is:
Excess-3 code for decimal digit d = four-bit binary representation of d + 3
| Decimal Digit | Digit + 3 | Excess-3 |
|---|---|---|
| 0 | 3 | 0011 |
| 1 | 4 | 0100 |
| 2 | 5 | 0101 |
| 3 | 6 | 0110 |
| 4 | 7 | 0111 |
| 5 | 8 | 1000 |
| 6 | 9 | 1001 |
| 7 | 10 | 1010 |
| 8 | 11 | 1011 |
| 9 | 12 | 1100 |
Example: encode decimal 47 in Excess-3.
4 + 3 = 7 → 0111
7 + 3 = 10 → 1010
Therefore:
4710 = 0111 1010 in Excess-3
Decoding Excess-3
To decode an Excess-3 digit:
- Convert the four-bit group to its ordinary binary numerical value.
- Subtract 3.
Example:
1001 = 9
9 − 3 = 6
Therefore 1001 in Excess-3 represents decimal digit 6.
Excess-3 is also a self-complementing code. Bitwise complementing the Excess-3 code of a decimal digit produces the Excess-3 code for its 9's complement.
Gray Code
Gray code is a non-weighted binary code in which two consecutive code words differ in only one bit position.
In ordinary binary counting, several bits can change at the same time. For example, moving from 0111 to 1000 changes all four bits. Gray code arranges adjacent values so that only one bit changes, reducing ambiguity when transitions are sensed physically.
Unit-Distance Property
The defining property of Gray code is its unit-distance property: adjacent code words have a Hamming distance of one, meaning exactly one bit changes between neighboring values.
| Decimal | Binary | Gray Code |
|---|---|---|
| 0 | 0000 | 0000 |
| 1 | 0001 | 0001 |
| 2 | 0010 | 0011 |
| 3 | 0011 | 0010 |
| 4 | 0100 | 0110 |
| 5 | 0101 | 0111 |
| 6 | 0110 | 0101 |
| 7 | 0111 | 0100 |
| 8 | 1000 | 1100 |
| 9 | 1001 | 1101 |
| 10 | 1010 | 1111 |
| 11 | 1011 | 1110 |
| 12 | 1100 | 1010 |
| 13 | 1101 | 1011 |
| 14 | 1110 | 1001 |
| 15 | 1111 | 1000 |
Binary to Gray Code Conversion
Gray conversion uses the Exclusive-OR (XOR) operation. XOR produces 1 when its two input bits are different and 0 when they are equal.
To convert binary to Gray code:
- Copy the most significant binary bit directly as the most significant Gray bit.
- For every following Gray bit, XOR the current binary bit with the binary bit immediately to its left.
For binary bits B and Gray bits G:
GMSB = BMSB
Each next G = previous B XOR current B
Worked Example: Binary 1010 to Gray Code
Binary:
1 0 1 0
- First Gray bit = 1.
- 1 XOR 0 = 1.
- 0 XOR 1 = 1.
- 1 XOR 0 = 1.
Therefore:
(1010)2 = (1111)Gray
Gray Code to Binary Conversion
To convert Gray code to binary:
- Copy the most significant Gray bit directly as the most significant binary bit.
- For each following position, XOR the previously obtained binary bit with the current Gray bit.
Worked Example: Gray 1111 to Binary
- First binary bit = 1.
- 1 XOR 1 = 0.
- 0 XOR 1 = 1.
- 1 XOR 1 = 0.
Therefore:
(1111)Gray = (1010)2
Generating Reflected Gray Code
Gray code is also known as reflected binary code because an n-bit sequence can be generated from an (n−1)-bit sequence by reflection.
For two-bit Gray code:
00
01
11
10To create three-bit Gray code:
- Write the two-bit sequence in its original order.
- Write the same sequence in reverse order.
- Prefix 0 to the original half.
- Prefix 1 to the reflected half.
000
001
011
010
110
111
101
100Uses of Gray Code
- Rotary and shaft encoders: reduces ambiguous readings when position changes between adjacent values.
- Position sensing: only one code bit changes between adjacent mechanical positions.
- Digital communication and conversion systems: useful where minimizing transition errors is desirable.
- Karnaugh-map ordering: adjacent cells are arranged using Gray-code ordering so neighboring combinations differ by one variable.
Let's Clarify
Imagine four switches representing a position sensor. If a transition requires several switches to change at once, they may not all change at exactly the same instant. For a brief moment the sensor can appear to show the wrong value. Gray code limits each adjacent transition to one changing bit, reducing this transition ambiguity.
BCD and Gray Code Compared
| Basis | BCD | Gray Code |
|---|---|---|
| Full name | Binary-Coded Decimal | Gray code |
| Main purpose | Represent decimal digits in binary-coded form. | Provide adjacent code words that differ by one bit. |
| Type | 8421 BCD is weighted. | Non-weighted. |
| Digit representation | Each decimal digit is encoded independently. | Code words are arranged according to unit-distance order. |
| Decimal 10 | 0001 0000 | Decimal 10 first maps to binary 1010, whose four-bit reflected Gray code is 1111. |
| Adjacent transition property | No requirement that only one bit changes. | Only one bit changes between consecutive code words. |
| Typical application | Decimal displays and decimal-oriented digital systems. | Encoders, sensing, transition-error reduction. |
Comparison of Decimal Codes
| Code | Weighted? | Weights or Rule | Self-Complementing? | Main Property |
|---|---|---|---|---|
| 8421 BCD | Yes | 8, 4, 2, 1 | No | Direct four-bit encoding of each decimal digit. |
| 2421 | Yes | 2, 4, 2, 1 | Yes | Weighted decimal code with weights summing to 9. |
| 84−2−1 | Yes | 8, 4, −2, −1 | Yes | Uses positive and negative positional weights. |
| Excess-3 | No | Add 3 to each decimal digit. | Yes | Offset decimal code. |
| Gray | No | Adjacent words differ by one bit. | Not treated as a decimal self-complementing code | Unit-distance transition property. |
Common Mistake
BCD and ordinary binary are not interchangeable. Decimal 25 is 11001 in pure binary, but BCD encodes the decimal digits separately: 2 → 0010 and 5 → 0101, giving 0010 0101.
Summary
- Decimal codes express decimal information through selected binary code words.
- 8421 BCD encodes every decimal digit separately using weights 8, 4, 2, and 1.
- 2421 and 84−2−1 are weighted self-complementing decimal codes.
- Excess-3 is obtained by adding 3 to each decimal digit before binary encoding and is self-complementing.
- Gray code is non-weighted and changes only one bit between consecutive code words.
- Binary-to-Gray uses adjacent-bit XOR; Gray-to-binary uses cumulative XOR from the most significant position.
Test Yourself
- Encode decimal 58 in 8421 BCD and Excess-3.
- Convert binary 110101 to Gray code and convert the resulting Gray code back to binary.
- Why is Gray code called a unit-distance code?
- Write short notes on:
a) Gray Code (2083) - Differentiate between BCD and Gray code. Convert (10)₁₀ to BCD. (3+2) (2081)
Hints:
- BCD: 5 → 0101, 8 → 1000, giving 0101 1000. Excess-3: 5+3=8 → 1000; 8+3=11 → 1011, giving 1000 1011.
- Copy the most significant bit, then XOR adjacent binary bits. For reverse conversion, copy the most significant Gray bit and XOR each new Gray bit with the previous binary result.
- Every pair of consecutive Gray-code words differs in exactly one bit position.
- Define Gray code, explain the one-bit transition property, describe binary/Gray conversion, and state uses such as encoders and position sensing.
- BCD represents decimal digits separately using weighted 8421 patterns; Gray is a non-weighted unit-distance code. Decimal 10 in BCD = 0001 0000.
1.8 Binary Storage and Registers
Definition
Binary storage is the storage of information as binary bits, while a register is a group of binary storage elements used to hold a binary word temporarily inside a digital system.
One storage element can remember one 0 or 1. Several such elements placed together can remember a complete binary value. An eight-bit register, for example, can hold a pattern such as 10110110 at one moment and a different eight-bit pattern later.
Detailed Explanation
Digital systems need to preserve information between operations. If every intermediate value disappeared immediately after being calculated, a processor could not execute a sequence of instructions. Binary storage elements provide memory of previous states.
Binary Storage Element
A binary storage element has two stable logical states:
- one state represents binary 0,
- the other state represents binary 1.
A bistable digital circuit such as a flip-flop can store one bit. The detailed internal construction of flip-flops belongs to sequential logic, but at this level the essential fact is that one storage element preserves one binary state until an operation changes it.
Register Structure
A register combines multiple one-bit storage elements so that several bits can be stored together.

If a register contains n storage elements, it stores an n-bit word.
For example:
- 4 storage elements → 4-bit register.
- 8 storage elements → 8-bit register.
- 16 storage elements → 16-bit register.
- 32 storage elements → 32-bit register.
An 8-bit register storing decimal 45 may contain:
00101101
Because:
32 + 8 + 4 + 1 = 45.
Register Operations
Depending on the design, a register can support operations such as:
- Load: place a new binary value into the register.
- Clear: set stored bits to 0.
- Read: use the stored value without necessarily changing it.
- Transfer: copy a stored value from one register or unit to another.
- Shift: move bit positions left or right in registers designed for shifting.
Parallel Storage
When all bits of a register are loaded at the same time through separate input lines, the operation is called parallel loading.
For a 4-bit register:
D3 D2 D1 D0 → Register → Q3 Q2 Q1 Q0
If the inputs are 1011 when a load operation occurs, the register stores 1011.
Register Capacity
The capacity of a register is normally stated by its number of bits.
An n-bit register has:
- n storage positions,
- 2n possible bit patterns.
For example, a 4-bit register can contain:
24 = 16 distinct bit patterns
from 0000 through 1111.
Registers and General Memory Compared
| Property | Register | General Memory |
|---|---|---|
| Basic role | Stores a small binary word close to active processing circuitry. | Stores larger collections of instructions and data. |
| Capacity | Usually very small. | Much larger. |
| Access | Designed for rapid direct use by digital processing circuitry. | Accessed through memory addressing mechanisms. |
| Typical content | Operands, intermediate results, control information. | Programs, data structures, stored values. |
Binary Word
A binary word is a group of bits treated as a single unit of information.
The meaning of a word depends on context. The same pattern could represent:
- an unsigned number,
- a signed number,
- a coded decimal digit or character,
- part of an instruction,
- a set of control flags.
This connects binary storage with the representations developed in 1.2 Binary Numbers, 1.6 Signed Binary Numbers, and 1.7 Decimal Codes. Storage elements preserve bits; the selected coding convention determines what those bits mean.
Let's Clarify
A row of numbered lockers provides a useful model. Each locker can hold one of two markers, 0 or 1. One locker is a one-bit storage element. Eight lockers in a row can hold an eight-bit word, so the complete row behaves like an eight-bit register.
Common Mistake
A register does not automatically determine whether its contents represent a positive number, negative number, character, or instruction. It stores a bit pattern. The interpretation depends on the digital system and the representation being used.
Summary
- A binary storage element preserves one bit, either 0 or 1.
- A register combines several storage elements to hold a multi-bit binary word.
- An n-bit register can store 2n distinct patterns.
- Common register actions include load, clear, read, transfer, and shift where supported.
- The meaning of a stored bit pattern depends on whether it is interpreted as binary, signed data, a code, or another digital representation.
Test Yourself
- What is a register, and how is its size related to the number of storage elements?
- How many different patterns can a 12-bit register store?
- Explain the relationship between a binary storage element, a register, and a binary word.
Hints:
- A register is a group of one-bit storage elements. n elements form an n-bit register.
- 212 = 4096 possible patterns.
- One storage element stores one bit; multiple elements form a register; the group of bits stored together is treated as a binary word.
1.9 Binary Logic
Definition
Binary logic is a system of logical operations in which variables have only two possible states, normally represented by 0 and 1.
A binary logic circuit receives one or more 0/1 inputs, applies a rule, and produces a 0/1 output. The rule may ask whether all inputs are 1, whether at least one is 1, whether an input should be inverted, or whether two inputs differ.
Detailed Explanation
Binary logic provides the decision-making foundation of digital circuits. Arithmetic circuits, control units, comparators, memory control, communication circuits, and processors are built from combinations of logical operations.
Binary logical values can be interpreted as:
| Binary Value | Logical Meaning | Other Common Interpretation |
|---|---|---|
| 0 | FALSE | LOW, OFF, inactive |
| 1 | TRUE | HIGH, ON, active |
Logic Variable
A logic variable is a variable that can take only two logical values: 0 or 1.
Examples:
A = 0 or 1
B = 0 or 1
A logic function produces an output based on one or more such inputs.
Truth Table
A truth table lists every possible input combination and the output produced by a logical operation.
For n independent binary inputs, the number of possible input combinations is:
2n
Thus:
- 1 input → 2 combinations.
- 2 inputs → 4 combinations.
- 3 inputs → 8 combinations.
- 4 inputs → 16 combinations.
NOT Operation
The NOT operation, also called logical inversion, produces the opposite binary value.
If A = 0, NOT A = 1.
If A = 1, NOT A = 0.
| A | NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
AND Operation
The AND operation produces 1 only when all of its required inputs are 1.
For two inputs A and B:
Y = A AND B
| A | B | A AND B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
A useful interpretation is a permission rule requiring two conditions. If both conditions are true, the output becomes true.
OR Operation
The OR operation produces 1 when at least one input is 1.
Y = A OR B
| A | B | A OR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Exclusive-OR Operation
The Exclusive-OR (XOR) operation produces 1 when its two inputs are different and 0 when they are equal.
| A | B | A XOR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
This is the operation used in the Gray-code conversion method described in 1.7 Decimal Codes.
Basic Operations Compared
| Operation | Output Becomes 1 When... | Typical Logical Meaning |
|---|---|---|
| NOT | Input is 0. | Opposite state. |
| AND | All required inputs are 1. | Every condition is satisfied. |
| OR | At least one input is 1. | One or more conditions are satisfied. |
| XOR | The two inputs are different. | Exactly one of two binary conditions is true. |
Combining Logic Operations
More complex binary decisions are formed by connecting basic logic operations.
Consider:
Y = (A AND B) OR C
The calculation follows this sequence:
A and B evaluated by AND → result combined with C using OR → final Y
| A | B | C | A AND B | Y = (A AND B) OR C |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 1 |
Binary Logic and Digital Hardware
The operations described mathematically are implemented physically using logic gates. A logic gate is a digital circuit designed to perform a logical operation on binary inputs.
The relationship is:
Binary inputs → logic gate operation → binary output
Large digital systems consist of many gates connected to perform:
- arithmetic,
- comparison,
- data selection,
- code conversion,
- memory control,
- decision making.
Let's Clarify
A college portal can illustrate logical conditions. Suppose a page becomes available only when a student is logged in AND registration is open. Both conditions must be true. If a support form can be accessed by a student OR a teacher, either condition is enough. If access should be allowed when exactly one of two modes is active, XOR expresses that difference condition.
Common Mistake
Logical OR is inclusive: when A = 1 and B = 1, A OR B is still 1. XOR is different because 1 XOR 1 = 0. XOR requires the two input bits to differ.
Summary
- Binary logic operates on two-state variables represented by 0 and 1.
- A truth table lists every possible input combination and its output.
- NOT inverts a bit, AND requires all inputs to be 1, and OR requires at least one input to be 1.
- XOR outputs 1 when two inputs differ and is used in Gray-code conversion.
- n binary inputs produce 2n possible input combinations.
- Logic gates implement binary logical operations physically in digital hardware.
Test Yourself
- Write the truth tables of NOT, AND, OR, and XOR.
- How many rows are required in a truth table with five independent binary inputs?
- Find Y for A = 1, B = 0, C = 1 if Y = (A AND B) OR C.
Hints:
- NOT reverses one bit. AND gives 1 only for 11. OR gives 0 only for 00. XOR gives 1 for 01 and 10.
- 25 = 32 input combinations.
- A AND B = 0; 0 OR 1 = 1, so Y = 1.
Exam Questions
- Convert the following as indicated:
a) (F4B.B)16 to Decimal
b) (110.625)10 to Binary and Octal (2083) - Write short notes on:
a) Gray Code (2083) - Perform the following conversion
a) (A57)₁₆ to binary
b) (110001)₂ to octal (2.5+2.5) (2081) - Differentiate between BCD and Gray code. Convert (10)₁₀ to BCD. (3+2) (2081)
- Perform the following operations:
a. (011101)2-(110011)2 using 2's complement
b. (89344)10-(98654)10 using 9's complement (2080) - Differentiate analog computer with digital computer. (2078)
- How binary addition is done? Show binary addition of (11001) with (11011). (2078)
Whole Chapter Summary
Digital Systems
Digital systems work with discrete states, usually binary 0 and 1, while analog systems work with continuously varying quantities. Digital representation supports reliable logic processing, convenient storage, copying, and programmable computation.
Binary Numbers
Binary is the base-2 positional system used directly by digital hardware. Every bit position represents a power of 2, and binary arithmetic follows base-2 carry and borrow rules such as 1 + 1 = 102.
Number Base Conversion
Conversion changes the representation of a value without changing the value itself. Positional expansion converts numbers to decimal, repeated division converts decimal integers, repeated multiplication converts decimal fractions, and power-of-two grouping handles binary-octal and binary-hexadecimal conversion.
Octal and Hexadecimal Numbers
Octal is base 8 and represents three binary bits per digit. Hexadecimal is base 16 and represents four binary bits per digit, making both systems compact forms of long binary strings.
Complements
Complements allow subtraction to be performed through addition. Binary systems use 1's and 2's complements, while decimal complement arithmetic uses 9's and 10's complements.
Signed Binary Numbers
Signed representations encode positive and negative values using sign-magnitude, 1's complement, or 2's complement. Two's complement provides one zero representation and an n-bit range from −2n−1 to 2n−1−1.
Decimal Codes
Decimal codes translate decimal information into binary patterns. 8421 BCD represents each decimal digit separately, 2421 and 84−2−1 are weighted self-complementing codes, Excess-3 adds three to each digit, and Gray code provides one-bit transitions between adjacent words.
Binary Storage and Registers
A binary storage element holds one bit, and a register groups several storage elements to hold a binary word. An n-bit register has n bit positions and can store 2n distinct binary patterns.
Binary Logic
Binary logic processes 0/1 values using operations such as NOT, AND, OR, and XOR. Truth tables describe every input-output combination, while logic gates implement these rules as digital circuits.
Key Formulas and Points Sheet
| Formula or Rule | Meaning |
|---|---|
| Positional value = Σ digit × baseposition | General method for evaluating a positional number. |
| Decimal integer → base r: repeated division by r | Read remainders from bottom to top. |
| Decimal fraction → base r: repeated multiplication by r | Read extracted integer parts from top to bottom. |
| 1 octal digit = 3 binary bits | Because 8 = 23. |
| 1 hexadecimal digit = 4 binary bits | Because 16 = 24. |
| 1 + 1 = 102 | Binary sum 0 with carry 1. |
| (r−1)'s complement = (rn−1)−N | General diminished radix complement. |
| r's complement = rn−N | General radix complement. |
| 2's complement = 1's complement + 1 | Standard negative-number and subtraction representation in binary. |
| 10's complement = 9's complement + 1 | Decimal radix complement. |
| 2's complement range = −2n−1 to 2n−1−1 | Range of an n-bit signed 2's complement number. |
| Sign-magnitude range = −(2n−1−1) to +(2n−1−1) | n-bit sign-magnitude range. |
| 1's complement range = −(2n−1−1) to +(2n−1−1) | n-bit 1's complement range. |
| Excess-3 code = binary(digit + 3) | Encoding rule for each decimal digit. |
| Binary → Gray: first bit same; each next Gray bit = adjacent binary bits XOR | Binary-to-Gray conversion. |
| Gray → Binary: first bit same; each next binary bit = previous binary bit XOR current Gray bit | Gray-to-binary conversion. |
| n binary inputs → 2n truth-table rows | Number of possible binary input combinations. |
| n-bit register → 2n possible patterns | Number of distinct bit patterns that fit in the register. |
| AND = 1 only when all required inputs are 1 | Logical conjunction. |
| OR = 1 when at least one input is 1 | Logical inclusive OR. |
| XOR = 1 when two inputs differ | Exclusive-OR rule used in Gray conversion. |
Last-Minute Revision Sheet
| Concept | Trigger Phrase | Recall Cue |
|---|---|---|
| Digital system | Discrete states | 0 / 1, LOW / HIGH |
| Analog system | Continuous quantity | Infinite values across a range |
| Binary | Base 2 | Digits 0, 1; powers of 2 |
| Binary fraction | Right of binary point | 2−1, 2−2, 2−3 |
| Binary addition | Carry at 2 | 1 + 1 = 10 |
| Base to decimal | Positional expansion | digit × baseposition |
| Decimal integer conversion | Repeated division | Remainders bottom → top |
| Decimal fraction conversion | Repeated multiplication | Integer parts top → bottom |
| Binary ↔ octal | Groups of 3 | 8 = 23 |
| Binary ↔ hexadecimal | Groups of 4 | 16 = 24 |
| Octal | Base 8 | 0–7 |
| Hexadecimal | Base 16 | 0–9, A–F |
| 1's complement | Invert bits | 0 ↔ 1 |
| 2's complement | Invert + 1 | 1's complement + 1 |
| 9's complement | Subtract each digit from 9 | 9 − digit |
| 10's complement | 9's complement + 1 | Decimal radix complement |
| 2's-complement subtraction | Add complement | Carry → discard; no carry → negative |
| 1's-complement subtraction | End-around carry | Carry → add back |
| Sign-magnitude | Sign bit + magnitude | Two zeros |
| 1's complement signed | Negative = inverted positive | Two zeros |
| 2's complement signed | Negative = invert + 1 | One zero; asymmetric range |
| BCD | Each decimal digit separately | 10 → 0001 0000 |
| 8421 BCD | Weighted code | 8, 4, 2, 1 |
| 2421 | Weighted self-complementing | 2, 4, 2, 1 |
| 84−2−1 | Positive + negative weights | 8, 4, −2, −1 |
| Excess-3 | Add 3 | Digit + 3 → four-bit binary |
| Gray code | Unit distance | One bit changes between adjacent words |
| Binary → Gray | Adjacent XOR | First bit unchanged |
| Gray → Binary | Cumulative XOR | Previous binary XOR current Gray |
| Binary storage | One element → one bit | Two stable states |
| Register | Group of storage elements | n elements → n-bit word |
| Truth table | All input combinations | n inputs → 2n rows |
| NOT | Invert | 0→1, 1→0 |
| AND | All true | 11 → 1 |
| OR | At least one true | 00 only case giving 0 |
| XOR | Inputs differ | 01 / 10 → 1 |


