0% found this document useful (0 votes)
4 views

Lecture 05_Repesentation (1)

Uploaded by

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

Lecture 05_Repesentation (1)

Uploaded by

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

Introduction

• All information must be rendered into binary in


order to be stored on a computer.
• Besides numbers, almost all applications must
store characters and string information.
• Images are pervasive in today’s internet world and
must be rendered in binary to be handled by
internet browsers.

Tanvir Ahammad, Dept. of CSE, JnU


Introduction
• Examples
Real World Computer
Data Input device Data

Dear Mom: Keyboard 10110010…

Digital
10110010…
camera

Tanvir Ahammad, Dept. of CSE, JnU


Format must be appropriate
• The internal representation must be
appropriate for the type of processing to
take place (e.g., text, images, sound)

Tanvir Ahammad, Dept. of CSE, JnU


Standards Organizations
• ISO – International Standards Organization
• CSA – Canadian Standards Association
• ANSI – American National Standards
Institute
• IEEE – Institute for Electrical and
Electronics Engineers
• Etc.

Tanvir Ahammad, Dept. of CSE, JnU


Examples of Standards
Type of Data Standards
Alphanumeric ASCII, EBCDIC, Unicode

Image JPEG, GIF, PCX, TIFF

Motion picture MPEG-2, Quick Time

Sound Sound Blaster, WAV, AU

Outline graphics/fonts PostScript, TrueType, PDF

Tanvir Ahammad, Dept. of CSE, JnU


Why Standards?
• Standard are “arbitrary”
• They exist because they are
– Convenient
– Efficient
– Flexible
– Appropriate
– Etc.

Tanvir Ahammad, Dept. of CSE, JnU


Alphanumeric Data
• Problem: Distinguishing between the number 123
(one hundred and twenty-three) and the characters
“123” (one, two, three)
• Four standards for representing letters (alpha) and
numbers
– BCD – Binary-coded decimal
– ASCII – American standard code for information
interchange
– EBCDIC – Extended binary-coded decimal interchange
code
– Unicode

Tanvir Ahammad, Dept. of CSE, JnU


Standard Alphanumeric Formats
• BCD Next 2 slides
• ASCII
• EBCDIC
• Unicode

Tanvir Ahammad, Dept. of CSE, JnU


Binary-Coded Decimal (BCD)
▪ Decimal numbers are more natural to humans.
Binary numbers are natural to computers. Quite
expensive to convert between the two.
▪ If little calculation is involved, we can use some
coding schemes for decimal numbers.
▪ One such scheme is BCD, also known as the 8421
code.
▪ Represent each decimal digit as a 4-bit binary
code.

Tanvir Ahammad, Dept. of CSE, JnU


Binary-Coded Decimal (BCD)
• Four bits per digit Digit Bit pattern
0 0000

Note: the following 1 0001


bit patterns are not 2 0010
used: 3 0011
4 0100
1010
5 0101
1011
1100 6 0110
1101 7 0111
1110 8 1000
1111 9 1001

Tanvir Ahammad, Dept. of CSE, JnU


Example
• 709310 = ? (in BCD)

7 0 9 3

0111 0000 1001 0011

Tanvir Ahammad, Dept. of CSE, JnU


Binary-Coded-Decimal (BCD)

▪ Examples:
(234)10 = (0010 0011 0100)BCD
(7093)10 = (0111 0000 1001 0011)BCD
(1000 0110)BCD = (86)10
(1001 0100 0111 0010)BCD = (9472)10
Notes: BCD is not equivalent to binary.
Example: (234)10 = (11101010)2

Tanvir Ahammad, Dept. of CSE, JnU


Standard Alphanumeric Formats
• BCD
• ASCII Next 22 slides
• EBCDIC
• Unicode

Tanvir Ahammad, Dept. of CSE, JnU


The Problem
• Representing text strings, such as
“Hello, world”, in a computer

Tanvir Ahammad, Dept. of CSE, JnU


Codes and Characters
• Each character is coded as a byte
• Most common coding system is ASCII
(Pronounced ass-key)
• ASCII = American National Standard Code
for Information Interchange
• Defined in ANSI document X3.4-1977

Tanvir Ahammad, Dept. of CSE, JnU


ASCII Features
• 7-bit code
• 8th bit is unused (or used for a parity bit)
• 27 = 128 codes
• Two general types of codes:
– 95 are “Graphic” codes (displayable on a
console)
– 33 are “Control” codes (control features of the
console or communications channel)

Tanvir Ahammad, Dept. of CSE, JnU


ASCII Chart

ENG-1204 Md. Manowarul Islam, Dept. of CSE, JnU


ENG-1204 Md. Manowarul Islam, Dept. of CSE, JnU
Most significant bit

Least significant bit

ENG-1204 Md. Manowarul Islam, Dept. of CSE, JnU


e.g., ‘a’ = 1100001

ENG-1204 Md. Manowarul Islam, Dept. of CSE, JnU


“Hello, world” Example

Binary Hexadecima Decima


01001000 l l
H = = 48 = 72
e = 01100101 = 65 = 101
l = 01101100 = 6C = 108
l = 01101100 = 6C = 108
o = 01101111 = 6F = 111
, = 00101100 = 2C = 44
= 00100000 = 20 = 32
w = 01110111 = 77 = 119
o = 01100111 = 67 = 103
r = 01110010 = 72 = 114
l = 01101100 = 6C = 108
d = 01100100 = 64 = 100

Tanvir Ahammad, Dept. of CSE, JnU


Standard Alphanumeric Formats
• BCD
• ASCII
• EBCDIC Next 1 slides
• Unicode

Tanvir Ahammad, Dept. of CSE, JnU


EBCDIC
• Extended BCD Interchange Code
(pronounced ebb’-se-dick)
• 8-bit code
• Developed by IBM
• Rarely used today
• IBM mainframes only

Tanvir Ahammad, Dept. of CSE, JnU


Standard Alphanumeric Formats
• BCD
• ASCII
• EBCDIC
• Unicode Next 2 slides

Tanvir Ahammad, Dept. of CSE, JnU


Unicode
• 16-bit standard
• Developed by a consortia
• Intended to supercede older 7- and 8-bit
codes

Tanvir Ahammad, Dept. of CSE, JnU


Keyboard Input
• Key (“scan”) codes are converted to ASCII
• ASCII code sent to host computer
• Received by the host as a “stream” of data
• Stored in buffer
• Processed
• Etc.

Tanvir Ahammad, Dept. of CSE, JnU

You might also like