U14 Binary Codes
U14 Binary Codes
Binary Codes
■ BCD Code •A number with k decimal digits will
require 4k bits in BCD.
•Decimal 396 is represented in BCD
with 12bits as 0011 1001 0110
•Each group of 4 bits representing one
decimal digit
• A decimal number in BCD is the same
as its equivalent binary number only
when the number is between 0 and 9
• A BCD number greater than 10 looks
different from its equivalent binary
number, even though both contain 1's
and 0's.
• Moreover, the binary combinations
1010 through 1111 are not used and
have no meaning in BCD.
Binary Codes
Example:
Consider decimal 185 and its corresponding value in BCD and binary:
■ BCD Addition
Binary Codes
Example:
Consider the addition of 184 + 576 = 760 in BCD:
■ Decimal Arithmetic
Binary Codes
■ Other Decimal Codes
Binary Codes
■ Gray Code
Binary Codes
■ ASCII Character Code
Binary Codes
■ ASCII Character Code
ASCII Character Codes
• American Standard Code for Information Interchange
• A popular code used to represent information sent
as character-based data
• It uses 7-bits to represent:
– 94 Graphic printing characters.
– 34 Non-printing characters
• Some non-printing characters are used for text
format (e.g. BS = Backspace, CR = carriage return)
• Other non-printing characters are used for record
marking and flow control (e.g. STX and ETX start and
end text areas).
ASCII Properties
ASCII has some interesting properties:
Digits 0 to 9 span Hexadecimal values 3016 to 3916
Upper case A -Z span 4116 to 5A16
Lower case a -z span 6116 to 7A16
• Lower to upper case translation (and vice versa)
occurs by flipping bit 6.
Binary Codes
■ Error-Detecting Code
To detect errors in data communication and processing, an eighth bit is sometimes
added to the ASCII character to indicate its parity.
A parity bit is an extra bit included with a message to make the total number of 1's
either even or odd.
Example:
Consider the following two characters and their even and odd parity:
Binary Codes
■ Error-Detecting Code