3 - BCD, Alphanumeric Codes
3 - BCD, Alphanumeric Codes
Alphanumeric Code
ASCII Code
2
OUTCOMES
• Ascii code.
3
BCD
Definition:
BCD (Binary-Coded Decimal) is a way of encoding each digit of a decimal
number separately using a fixed number of binary bits.
Binary-Coded Decimal (BCD) is a representation method used to encode
decimal digits using binary digits (0s and 1s).
One of the earlier method of encoding decimal numbers.
A 4-bit BCD (Binary Coded Decimal) can represent a total of 16 different
characters. Each of the 4 bits can have two possible values (0 or 1), so there
are a total of 2^4 = 16 possible combinations. However, in BCD, only the
values from 0 to 9 are used to represent decimal digits.
BCD….
Definition:
Binary coded decimal (BCD) is a system of writing numbers that assigns a
four-digit binary code to each digit 0 through 9 in a decimal (base-10)
numeral.
The four-bit BCD code for any particular single base-10 digit is represented as
follows:
• 0 = 0000 5 = 0101
• 1 = 0001 6 = 0110
• 2 = 0010 7 = 0111
• 3 = 0011 8 = 1000
• 4 = 0100 9 = 1001
BCD Exercise….
Question: write 4-bit and 6-bit BCD codes for the following decimal
numbers?
1) 5
2) 56 = 0101 0110 (one is done for you) (000101 000110 6-bit BCD)
3) 90
4) 23
5) 11
6) 34
BCD Exercise….
Question: find the decimal numbers represented by following BCD codes?
1) 0000 0111 1001 (4 bit BCD) Answer: 079
2) 001001 000000 000100 (6 bit BCD) Answer : 904
BCD….
How BCD works::
In BCD, each decimal digit (0-9) is represented by its 4-bit binary equivalent.
This means each decimal digit is encoded using exactly four binary bits.
Example:
Let's take the decimal number 362. In BCD, each digit is encoded separately:
3 is 0011 in BCD (binary representation of 3).
6 is 0110 in BCD (binary representation of 6).
2 is 0010 in BCD (binary representation of 2).
To represent a multi-digit number 362 in BCD, you group the BCD codes of each
digit together. So, for 362, the BCD representation would be 0011 0110 0010.
Why BCD is used ?
1.Advantages:
1. BCD is simple to understand and work with because it directly represents
decimal digits.
2. It's easy to convert BCD to decimal and vice versa.
2.Disadvantages:
1. The major drawback of 4-bit BCD representation is that it can represent
the decimal numbers only and cannot represent the various characters.
3.Usage:
1. BCD is often used in applications where decimal calculations are needed,
like calculators and financial systems, because it makes it easier to
perform arithmetic operations with decimal numbers.
BCD to decimal and decimal to BCD conversions
Conversions:
1) BCD to Decimal: To convert BCD to decimal, you group the BCD bits in sets
of four and convert each set to its decimal equivalent.
i.e.
BCD: 0101 0010
Decimal: 5 2
2) Decimal to BCD: To convert decimal to BCD, you break down each decimal
digit into its 4-bit binary equivalent and combine them.
i.e.
Decimal: 7 6
16
EBCDIC
• EBCDIC, which stands for Extended Binary Coded Decimal Interchange
Code, is a character encoding scheme .
• Encoding Format: EBCDIC is an 8-bit encoding scheme, which means it
uses 8 bits (or one byte) to represent each character. This allows for a
total of 256 possible characters, including letters, numbers, special
symbols, and control codes.
• EBCDIC is a character encoding scheme that was developed by IBM for its
mainframe and midrange computer systems. While it played a crucial role
in early computing, its usage has significantly declined in favor of ASCII
and Unicode on modern computing platforms.
17
The character that can be encoded by EBCDIC
EBCDIC (Extended Binary Coded Decimal Interchange Code) is another character encoding method,
primarily used in early IBM mainframe computers.
the characters encoded by EBCDIC:
Uppercase letters: A-Z
Lowercase letters: a-z (in some variations)
Digits: 0-9
Punctuation marks: . , ; : ! ? ' " (and more)
Special characters: @ # $ % & * ( ) _ + - = / \ | [ ] { } < > and more
NOTE: EBCDIC encoding varies slightly between different EBCDIC code pages or versions, and there
were several variations used in different regions and for different purposes. For example, EBCDIC-US,
EBCDIC-UK, and EBCDIC-FR were used in the United States, the United Kingdom, and France,
respectively.
EBCDIC is less common today than ASCII or UTF-8 encoding. Modern computer systems and
programming languages typically use ASCII or Unicode-based encodings like UTF-8, which can represent
a much wider range of characters from various languages and scripts, making them more suitable for
internationalization and modern computing needs.
18
Codes Extended Alphanumeric Codes(Unicode encoding system) :
Extended alphanumeric encoding systems are expansions of traditional character
encoding schemes, like BCD, ASCII (American Standard Code for Information
Interchange), that allow for a broader range of characters to be represented,
including special characters, symbols, and characters from various languages and
writing systems.
Extended alphanumeric encoding systems, particularly those based on Unicode like UTF-8, UTF-
16, and UTF-32, allow computers to handle a wide range of characters from different languages,
writing systems, and symbols. These encoding systems play a crucial role in modern
communication, data storage, software development, and global information exchange.
Unicode encoding system
• Unicode came into existence to express a huge variety of characters that
include letters, numbers, symbols, and even special characters from
different languages, like smiley faces and hearts. It's a way to make sure
that computers can handle text in lots of languages
• Unicode uses a variable number of bits (usually 8, 16, or 32 bits) to
represent characters from different writing systems worldwide.
• In Unicode Each character is assigned a unique pattern of 0s and 1s that
the computer can easily recognize.
20
Unicode uses
Uses of Unicode
Language Support: Unicode makes it possible for you to type, read, and
display text in different languages. So, whether you're writing in English,
Chinese, Arabic, or any other language, Unicode helps your computer
understand and show the right characters.
21
Unicode uses
Digital Content: Websites, apps, and social media platforms use Unicode
to show text and symbols correctly. This means you can post and view
content in various languages and scripts without any issues.
In summary, Unicode is like a language translator for computers. It lets
them understand and work with text from all corners of the world, making
communication, content creation, and digital interaction possible across
languages and cultures.
Unicode enabled multilingual computing, enabled the coexistence of
various languages within a single system. In the context of Digital Logic
Design (DLD), Unicode serves as a cornerstone for character
representation and processing.
22
Unicode variant
UTF-8 (Unicode Transformation Format - 8-bit) It can represent all Unicode characters
using one to four bytes. "UTF-8 encodes a character into a binary string of one, two,
three, or four bytes.“UTF-8 can represent over 1 million different characters.
UTF-8 encoding is its backward compatibility with ASCII. The first 128 characters in
the Unicode library match those in the ASCII library, and UTF-8 translates these 128
Unicode characters into the same binary strings as ASCII.
UTF-8 is widely used on the internet due to its efficiency in encoding common
characters while accommodating a broad range of characters.
UTF-16 (Unicode Transformation Format - 16-bit): UTF-16 uses 16-bit units and can
represent all Unicode characters using one or two 16-bit units (2 or 4 bytes). "UTF-16
encodes a Unicode character into a string of either two or four bytes.“
UTF-16 can theoretically represent over 65,000 different characters using two 16-bit
units (2 bytes) per character.
23
Unicode variants….
UTF-32 (Unicode Transformation Format - 32-bit)
UTF-32: Like the other variants, it can represent all Unicode characters,
using a fixed 32-bit unit (4 bytes) for each character. UTF-32 is less
commonly used due to its higher memory requirements.
24
Unicode variants differences
In terms of their ability to represent characters, all these Unicode
encoding variants are equal. The choice between them usually depends on
factors like memory efficiency, platform compatibility, and performance
requirements.
• Practical Usage:
• UTF-8 is dominant for web content and data interchange due to its space
efficiency and compatibility.
• UTF-16 is used in Windows systems and certain programming contexts.
• UTF-32 is rarely used outside of specialized applications requiring
consistent memory usage.
25
Unicode variants differences
UTF-8 is backward-compatible with ASCII, making it suitable for
systems and applications that rely heavily on ASCII characters.
UTF-16 is used extensively in Windows systems and some programming
languages, where two-byte units can represent a substantial portion of
characters.
UTF-32 is less commonly used due to its memory requirements
26
Unicode character set
The Unicode character set refers to a standardized collection of characters,
symbols, and special characters that have been assigned unique code points
(numeric identifiers) for representation in digital systems.
This character set is designed to include characters from various languages,
writing systems, symbols, emoji's, and more, with the aim of enabling
multilingual computation.
As of Unicode 14.0, which was released in September 2021, the Unicode
standard defines over 143,000 characters.
27
Unicode character set……
It's important to note that the Unicode character set is continually evolving.
With each new version of the Unicode standard, new characters may be
added to accommodate the needs of global communication, technical
requirements, and cultural representation.
All major Unicode encoding variants (UTF-8, UTF-16, and UTF-32) are
capable of representing the entire range of characters defined by the
Unicode standard.
The differences between these variants lie in their encoding mechanisms
and memory usage, not in the number of characters they can represent.
28
Space taken by UTF encoding schemes
UTF-8:
Uses 1 byte for most common characters, including ASCII characters (0-127).
Can use 2, 3, or 4 bytes for less common characters, allowing it to represent a wide
range of characters from different scripts and symbols.
UTF-16:
Uses 2 bytes (16 bits) for most characters, including many common international
characters.
Uses 4 bytes (32 bits) for less common characters and certain special characters
represented by surrogate pairs.
UTF-32:
Uses a fixed 4 bytes (32 bits) for every character, regardless of its rarity or uniqueness.
Provides a consistent and simple encoding scheme but may be less memory-efficient
than UTF-8 or UTF-16 for text that primarily consists of common characters.
29
Space taken by UTF……..
In summary, UTF-8 and UTF-16 are variable-length encodings, with UTF-8
being more space-efficient for common characters, while UTF-32 is a
fixed-length encoding where every character occupies 4 bytes.
The choice of encoding depends on the specific requirements and the
range of characters that need to be represented.
30
Thank You…!