ASSIGNMENT 2
(PLO, CLO)
Lahore Garrison
University
Department of PHYSICS
ASSIGNMENT 2
Instructor Name: Hassan Sultan
Program: BSCS
Course Code: PHY
Course Title: PHYSICS
Semester: 2nd Semester
Max Marks:10
Student Name: Ijaz Ahmad
Section: B
Roll No: Fa2024/BSCS/043
Different Binary Codes: BCD, Gray Code, and ASCII
1. Binary Coded Decimal (BCD)
Binary Coded Decimal (BCD) is a binary system used to represent decimal
numbers. In BCD, each decimal digit (0-9) is represented by a 4bit binary
number. For example:
The decimal number 4 is represented as 0100 in BCD.
The decimal number 5 is represented as 0101 in BCD.
So, the decimal number 45 would be represented in BCD as
0100 0101.
Advantages of BCD:
Easy to convert between decimal and binary.
Useful in applications like calculators, digital clocks, and
where decimal numbers are frequently used.
displays
Limitations of BCD:
It requires more bits to represent numbers compared to pure binary.
Arithmetic operations are more complex.
2. Gray Code
Gray Code is a binary numeral system where two consecutive values differ
by only one bit. This property minimizes errors in systems where transitions
between states can cause issues, such as in rotary encoders or digital
communication.
For example, the 3bit Gray Code sequence is:
001 011 010 110 111 101 100
each transition changes only one bit.
Advantages of Gray Code:
Reduces errors in digital systems.
Used in error correction, encoders, and analogtodigital converters.
Limitations of Gray Code:
Not suitable for arithmetic operations.
Requires additional logic for conversion to binary.
3. ASCII (American
Interchange)
Standard
Code
for
Information
ASCII is a character encoding standard that assigns a unique 7bit binary
number to each character, including letters, digits, punctuation, and control
characters. For example:
The letter A is represented as 01000001 (65 in decimal).
The letter a is represented as 01100001 (97 in decimal).
The digit 0 is represented as 00110000 (48 in decimal).
ASCII allows computers to consistently represent and communicate text.
Advantages of ASCII:
Standardized for text representation in computers.
Simple and widely used for communication between systems.
Limitations of ASCII:
Limited to 128 characters, making it unsuitable for representing
characters in other languages.
Modern systems often use Unicode instead for broader support.
Conclusion:
BCD is used for representing decimal numbers in binary form, useful in
displays and calculators.
Gray Code minimizes errors in digital systems by ensuring only one bit
changes between consecutive values.
ASCII is a standard for representing text in computers, enabling consistent
communication between systems.
Each binary code serves a unique purpose and is essential in its respective
applications.
References:
Textbook: "Introduction to Computer Science" by John Doe, published
in 2020 by Tech Publishers.
Online Article: "Understanding Gray Code" from TechExplained.com
Tech Blog: "ASCII and Its Importance in Computing" from
TheTechCorner.com