0% found this document useful (0 votes)
21 views28 pages

Computer Codes

This document discusses different computer codes used to represent numeric, alphabetic, and alphanumeric data internally in computers. It describes binary coded decimal (BCD), extended binary coded decimal interchange code (EBCDIC), American standard code for information interchange (ASCII), Unicode, and collating sequences. BCD uses 6 bits per character and can represent 64 characters. EBCDIC and ASCII use 8 bits per character and can represent 256 characters. It provides examples of number representation and coding schemes for various computer codes.

Uploaded by

Jordan Dingayan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views28 pages

Computer Codes

This document discusses different computer codes used to represent numeric, alphabetic, and alphanumeric data internally in computers. It describes binary coded decimal (BCD), extended binary coded decimal interchange code (EBCDIC), American standard code for information interchange (ASCII), Unicode, and collating sequences. BCD uses 6 bits per character and can represent 64 characters. EBCDIC and ASCII use 8 bits per character and can represent 256 characters. It provides examples of number representation and coding schemes for various computer codes.

Uploaded by

Jordan Dingayan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

COMPUTER FUNDAMENTALS AND

PROGRAMMING
(Computer Codes)
ENGR. MIGUEL ALBERT D. CALIZAR, ECT
Learning Objectives
In this chapter you will learn about:

● Computer Data
● Computer codes: representation of data in binary
● Most commonly used computer codes
● Collating sequence
Data Types
● Numeric Data consists of only numbers 0, 1, 2, …, 9.
● Alphabetic Data consists of only the letters A, B, C, …, Z, in both
uppercase and lowercase, and blank character.
● Alphanumeric Data is a string of symbols where a symbol may be one of
the letters A, B, C, …, Z, in either uppercase or lowercase, or one of
the digits 0, 1, 2, …, 9, or a special character,
such as + - * / , . ( ) = etc.
Computer Codes
● Computer codes are used for internal representation of data in
computers.
● As computers use binary numbers for internal data representation,
computer codes use binary coding schemes.
● In binary coding, every symbol that appears in the data is represented
by a group of bits.
● The group of bits used to represent a symbol is called a byte.
● As most modern coding schemes use 8 bits to represent a symbol, the term
byte us often used to mean a group of 8 bits.
● Commonly used computer codes are BCD, EBCDIC, and ASCII.
BCD
● BCD stands for Binary Coded Decimal.
● It is one of the early computer codes.
● It uses 6 bits to represent a symbol.
● It can represent 64 (26) different characters.
Coding of Alphabetic and
Numeric Characters in BCD
BCD Code BCD Code
Char Octal Char Octal
Zone Digit Zone Digit
A 11 0001 61 N 10 0101 45
B 11 0010 62 O 10 0110 46
C 11 0011 63 P 10 0111 47
D 11 0100 64 Q 10 1000 50
E 11 0101 65 R 10 1001 51
F 11 0110 66 S 01 0010 22
G 11 0111 67 T 01 0011 23
H 11 1000 70 U 01 0100 24
I 11 1001 71 V 01 0101 25
J 10 0001 41 W 01 0110 26
K 10 0010 42 X 01 0111 27
L 10 0011 43 Y 01 1000 30
M 10 0100 44 Z 01 1001 31
Coding of Alphabetic and
Numeric Characters in BCD
BCD Code Octal
Character
Zone Digit Equivalent
1 00 0001 01
2 00 0010 02
3 00 0011 03
4 00 0100 04
5 00 0101 05
6 00 0110 06
7 00 0111 07
8 00 1000 10
9 00 1001 11
0 00 1010 12
BCD Coding Scheme(Example 1)
Example

Show the binary digits used to record the word BASE in BCD.
BCD Coding Scheme(Example 2)
Example

Using octal notation, show BCD coding for the word DIGIT.
EBCDIC
● EBCDIC stands for Extended Binary Coded Decimal Interchange Code.
● It uses 8 bits to represent a symbol.
● It can represent 256 (28) different characters.
Coding of Alphabetic and
Numeric Characters in BCD
Coding of Alphabetic and
Numeric Characters in BCD
Zoned Decimal Numbers
● Zoned decimal numbers are used to represent numeric values (positive,
negative, or unsigned) in EBCDIC.
● A sign indicator (C for plus, D for minus, and F for unsigned) is used
in the zone position of the rightmost digit.
● Zones for all other digits remain as F, the zone value for numeric
characters in EBCDIC.
● In zoned format, there is only one digit per byte.
Examples Zoned Decimal Numbers

Numeric EBCDIC Sign


Value Indicator
345 F3F4F5 F For unsigned

+345 F3F4C5 C for positive

-345 F3F4D5 D for negative


Packed Decimal Numbers
● Packed decimal numbers are formed from zoned decimal numbers in the
following manner:
○ Step 1: The zone half and the digit half of the rightmost byte are
reversed
○ Step 2: All remaining zones are dropped out

● Packed decimal format requires fewer number of bytes than zoned decimal
format for representing a number
● Numbers represented in packed decimal format can be used for arithmetic
operations
Examples of Conversion of Zoned
Decimal Numbers to Packed
Decimal Format
Numeric EBCDIC Sign
Value Indicator
345 F3F4F5 F For unsigned

+345 F3F4C5 C for positive

-345 F3F4D5 D for negative

3456 F3F4F5F6 03456F


EBCDIC Coding Scheme
Example

Using binary notation, write EBCDIC coding for the word BIT.
How many bytes are required for this representation?
ASCII
● ASCII stands for American Standard Code for Information Interchange.
● ASCII is of two types: ASCII-7 and ASCII-8
● ASCII-7 uses 7 bits to represent a symbol and can represent 128 (27)
different characters.
● ASCII-8 uses 8 bits to represent a symbol and can represent 256 (28)
different characters.
● First 128 characters in ACII-7 and ASCII-8 are same.
Coding of Numeric and
Alphabetic Characters in ASCII
Coding of Numeric and
Alphabetic Characters in ASCII
ASCII-7 Coding Scheme
Example

Write binary coding for the word BOY in ASCII-7.


How many bytes are required for this representation?
ASCII-8 Coding Scheme
Example

Write binary coding for the word SKY in ASCII-8.


How many bytes are required for this representation?
Unicode
● Why Unicode:
• No single encoding system supports all languages
• Different encoding systems conflict
● Unicode features:
• Provides a consistent way of encoding multilingual plain text
• Defines codes for characters used in all major languages of the world
• Defines codes for special characters, mathematical symbols, technical
symbols, and diacritics
• Capacity to encode as many as a million characters
• Assigns each character a unique numeric value and name
• Reserves a part of the code space for private use
• Affords simplicity and consistency of ASCII, even corresponding characters
have same code
• Specifies an algorithm for the presentation of text with bidirectional
behavior

● Encoding Forms:
• UTF-8, UTF-16, UTF-32
Collating Sequence
● Collating sequence defines the assigned ordering among the characters
used by a computer
● Collating sequence may vary, depending on the type of computer code used
by a particular computer
● In most computers, collating sequences follow the following rules:
1. Letters are considered in alphabetic order
(A < B < C … < Z)
2. Digits are considered in numeric order
(0 < 1 < 2 … < 9)
Sorting in EBCDIC
Example

Suppose a computer use EBCDIC as its internal representation of


characters. In which order will this computer sort the strings
23, A1, 1A?
Sorting in ASCII
Example

Suppose a computer use ASCII as its internal representation of


characters. In which order will this computer sort the strings
23, A1, 1A, a2, 2a, aA, and Aa?
Thank You!

You might also like