1.
Data and Number System
A number system is a way to represent and express numbers using a specific set of symbols
or digits.
Data and number systems form the basis of digital logic. The understanding of number
systems helps in the representation and processing of data in digital systems.
Each number system is defined by its base (radix), which indicates the total number of
unique digits, including zero.
1.1 Number System
Binary Number System
Radix / Base :- 2
Digits :- 0 and 1
Example :- (1011)₂
It is fundamental to digital electronics and logic systems.
Octal Number System
Radix / Base :- 8
Digits :- 0 to 7
Example :- (12)₈
Often used to simplify binary representation.
Decimal Number System
Radix / Base :- 10
Digits :- 0 to 9
Example :- (13)₁₀
The standard system for human calculations.
Hexadecimal Number System
Radix / Base :- 16
Digits :- 0 to 9 and A to F (A=10, B=11, C=12, D=13, E=14, F=15)
Example :- (1A)₁₆
Used in programming and memory addressing.
1.2 Conversions Between Number System
I. Decimal to Binary
Divide the decimal number by 2.
Write the remainder.
Continue until the quotient is 0.
Write the remainders in reverse order.
Example :- Convert (25)₁₀ to Binary.
25 ÷ 2 = 12R1 → 12 ÷ 2 = 6R0 → 6 ÷ 2 = 3R0 → 3 ÷ 2 = 1R1 → 1 ÷ 2 = 0R1
Binary :- (11001)₂
II. Decimal to Octal
Divide the decimal number by 8.
Write the remainder.
Continue until the quotient is 0.
Write the remainders in reverse order.
Example :- Convert (345)₁₀ to Octal.
345 ÷ 8 = 43R1 → 43 ÷ 8 = 5R3 → 5 ÷ 8 = 0R5
Octal :- (531)₈
III. Decimal to Hexadecimal
Divide the decimal number by 16.
Write the remainder.
Map remainders greater than 9 to letters (A=10, B=11, C=12, D=13, E=14 ,F=15).
Write the remainders in reverse order.
Example :- Convert (450)₁₀ to Hexadecimal.
450 ÷ 16 = 28R2 → 28 ÷ 16 = 1R12 (C) → 1 ÷ 16 = 0R1
Hexadecimal :- (1C2)₁₆
IV. Binary to Decimal
Multiply each binary digit by 2ⁿ (where n is the position form the right, starting at 0).
Example :- Convert (1011)₂ to Decimal.
(1×2³) + (0×2²) + (1×2¹) + (1×2⁰) = 8 + 0 + 2 + 1 = (11)₁₀
Decimal :- (11)₁₀
V. Binary to Octal
Group binary digits in sets of three from the right.
Convert each group to its octal equivalent.
Example :- Convert (110111)₂ to Octal.
110 (6 in Octal), 111( 7 in Octal) → (67)₈
Octal :- (67)₈
VI. Banary to Hexadecimal
Group binary digits in sets of four from the right.
Convert each group to its hexadecimal equivalent.
Example :- Convert (10110111)₂ to hexadecimal.
1011(B in Hexadecimal), 0111(7 in Hexadecimal) → B7₁₆
Hexadecimal :- (B7)₁₆
VII. Octal to Decimal
Multiply each octal digit by 8ⁿ (where n is the position from the right , starting at 0).
Example :- Convert (157)₈ to Decimal.
(1×8²) + (5×8¹) + (7×8⁰) = 64 + 40 + 7 =(111)₁₀
Decimal :- (111)₁₀
VIII. Octal to Binary
Convert each octal digit to its 3-bits binary equivalent.
Example :- Convert (37)₈ to Binary.
3 (011 in Binary) , 7 (111 in Binary) → (011111)₂
Binary :- (11111)₂
IX. Octal to Hexadecimal
Convert the octal number to binary (3 bits per digit).
Group binary digits in sets of four to convert to hexadecimal.
Example :- Convert (54)₈ to Hexadecimal.
(54)₈ = (101100)₂ = (01011000)₂ = (58)₁₆
Hexadecimal :- (58)₁₆
X. Hexadecimal to Decimal
Multiply each hexadecimal digit by 16ⁿ (where n is the position from the right, starting at 0).
Example :- Convert (1A3)₁₆ to Decimal.
(1×16²) + (10×16¹) + (3×16⁰) = 256 + 160 + 3 = (419)₁₀
Decimal :- (419)₁₀
XI. Hexadecimal to Binary
Convert each hexadecimal digit to its 4-bit binary equivalent.
Example :- Convert (F3)₁₆ to Binary.
F ( 1111 in Binary ) , 3 ( 0011 in Binary ) → (11110011)₂
Binary :- (11110011)₂
XII. Hexadecimal to Octal
Convert the hexadecimal number to binary (4 bits per digit).
Group binary digits in sets of three to convert to octal.
Example :- Convert (2F)₁₆ to Octal.
(2F)₁₆ = 00101111₂ = 000101111₂ = (257)₈
Octal :- (257)₈
1.3 Significance of Number Systems in Digital Logic
Data Representation
Binary and hexadecimal formats are used to represent data, instructions, and addresses in
digital systems.
Logical Operations
Binary numbers support Boolean algebra for designing and analyzing logic circuits.
Efficient Processing
Hexadecimal and octal simplify binary data representation, making it easier to read and
debug.
Memory Addressing
Hexadecimal numbers make memory locations compact and clear.
1.4 Applications of Number Systems
Binary
Used in digital circuits, processors, and communication protocols.
Octal
Found in older systems and specific programming applications.
Decimal
The standard number system for daily calculations and human-readable data representation.
Hexadecimal
Commonly used in assembly language, memory addressing, and debugging.
1.5 Summary Table
Number System Base Digits Used Example Applications
Binary 2 0 &1 (1010)₂ Digital circuits, processors
Octal 8 0 to 7 (12)₈ Unix permissions, older computing
Decimal 10 0 to 9 (10)₁₀ Human-readable data, calculators
Hexadecimal 16 0 to 9, A to F (A3)₁₆ Memory addressing, debugging, colors
2. Codes In Digital Logic
2.1 BCD (Binary-Coded Decimal)
Introduction
BCD (Binary-Coded Decimal) is a representation of decimal numbers where each digit of the
decimal number is encoded as a separate 4-bit binary value.
Format
Each decimal digit (0-9) is represented by a 4-bit binary equivalent.
Purpose
It allows numerical data to be easily represented, stored, and processed in digital systems,
especially in applications like calculators, digital clocks, and financial systems.
Key Feature
Unlike binary, BCD uses 4 bits for each decimal digit, making it easier to convert to and from
human-readable decimal numbers.
2.1.1 Representation of BCD
BCD Representation
Each decimal digit is encoded in 4 binary bits.
BCD Representation 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
Decimal Digit 1 2 3 4 5 6 7 8 9 0
Note :- BCD is distinct from pure binary representation because values above 1001 are invalid in BCD.
2.1.2 Usage of BCD
BCD is primarily used in systems where precision and human readability are important, such
as
Financial systems
To avoid rounding errors when handling decimal values.
Digital clocks
To store and display time in decimal format.
Calculators
To perform operations directly on decimal numbers.
POS systems (Point of Sale)
For processing prices and quantities in human-readable decimal format.
2.1.3 Conversion Examples
I. Decimal to BCD
Write each decimal digit as a 4-bit binary number.
Concatenate the binary representations.
Examples :- Convert (259)₁₀ to BCD.
2 : 0010
5 : 0101
9 : 1001
Answer : (259)₁₀ → (0010 0101 1001)ᴃᴄᴅ
II. BCD to Decimal
Split the BCD number into groups of 4 bits.
Convert each 4-bit group to its decimal equivalent.
Examples :- Convert (0011 0111 1001)ᴃᴄᴅ to Decimal
0011 : 3
0111 : 7
1001 : 9
Answer : (0011 0111 1001)ᴃᴄᴅ → (379)₁₀
III. BCD Addition (Example)
When adding BCD numbers, ensure the result for each digit is valid (0-9). If a result exceeds
9, adjust it by adding (6)ᴃᴄᴅ (0110).
Example :- Add (9)ᴃᴄᴅ (1001) and (7)ᴃᴄᴅ (0111).
Add : 1001 + 0111 = 11000 (invalid BCD).
Correct : 11000 – 1010 + 0110 = 0001 0110 (16ᴃᴄᴅ).
Advantages of BCD
Simplifies conversion between human-readable decimal and binary.
Avoids rounding errors common in floating-point arithmetic.
Ideal for devices requiring precise decimal representation.
Disadvantages of BCD
Inefficient storage: Uses more bits compared to pure binary.
Slower arithmetic operations due to additional encoding and correction steps.
2.2 ASCII (American Standard Code for Information Interchange)
2.2.1 Introduction and Usage of ASCII
Definition
ASCII is a character encoding standard used to represent text in computers, communication
equipment, and other devices. Each character is assigned a unique numerical code.
Key Features
Character Set : Contains 128 characters (7-bit binary representation).
Printable Characters : Letters (A-Z, a-z), digits (0-9), punctuation marks, and symbols.
Control Characters : Non-printable characters used for controlling devices (e.g., newline,
tab, backspace).
Extension : Extended ASCII uses 8 bits (256 characters) for additional symbols and language
support.
Usage of ASCII
Text Representation : Used for encoding text in computer files, emails, and web pages.
Data Communication : Commonly used in protocols (e.g., HTTP, FTP) to ensure text data is
correctly transmitted.
Programming : Used to manipulate characters and strings in programming languages.
Input/Output : Enables devices like keyboards and displays to interpret character codes.
2.2.2 Representation and Conversion Examples
ASCII Table (Partial View)
Character Decimal Hexadecimal Binary
A 65 41 01000001
B 66 42 01000010
a 97 61 01100001
b 98 62 01100010
0 48 30 00110000
1 49 31 00110001
Space 32 20 00100000
Enter (CR) 13 0D 00001101
Representation in Binary, Decimal, and Hexadecimal
I. ASCII to Binary
Process : Convert the ASCII decimal value of a character into binary.
Find the ASCII decimal equivalent.
Convert the decimal to binary (8 bits).
Example : Convert character 'A' to binary.
ASCII Decimal Value of 'A' = 65.
Binary Conversion → 01000001.
Answer : 'A' → 01000001
II. Binary to ASCII
Process : Convert an 8-bit binary value to its corresponding ASCII character.
Convert the ASCII decimal value of a character into binary.
Find the corresponding ASCII character.
Example : Convert 01100001 to its ASCII character.
Binary 01100001 → Decimal 97. '
ASCII Decimal 97 → ' a '.
Answer : 01100001 → ' a '.
III. ASCII to Hexadecimal
Process : Convert the ASCII decimal value of a character into hexadecimal.
Find the ASCII decimal equivalent.
Convert the decimal to hexadecimal.
Example : Convert character 'B' to hexadecimal.
ASCII Decimal Value of 'B' = 66.
Hexadecimal Conversion → 42.
Answer : 'B' → 42
IV. Hexadecimal to ASCII
Process : Convert a hexadecimal value to its corresponding ASCII character.
Convert the hexadecimal value to decimal.
Find the corresponding ASCII character.
Example: Convert 61 to its ASCII character.
Hexadecimal 61 → Decimal 97.
ASCII Decimal 97 → 'a'.
Answer : 61 → 'a'.
V. ASCII to Decimal
Process : Convert a character directly to its ASCII decimal value.
Example : Convert 'C' to its ASCII decimal value.
ASCII Value of 'C' = 67.
Answer : 'C' → 67.
VI. Decimal to ASCII
Process : Convert a decimal number to its corresponding ASCII character.
Example : Convert 72 to its ASCII character.
Decimal 72 → ASCII Character 'H'.
Answer : 72 → 'H'.
VII. Text to ASCII Codes
Map each character to its corresponding ASCII decimal value.
Example : Convert "Hi!" to ASCII codes.
'H' → 72
'i' → 105
'!' → 33
Answer : 72, 105, 33.
VIII. ASCII Codes to Text
Map each decimal value to its character.
Example : Convert 72, 105, 33 to text.
72 → 'H'
105 → 'i'
33 → '!'
Answer : "Hi!".