chapter 2: data representation - radford.edumhtay/cpsc352/lecture_pdf/ch02poca.pdf · 2-5 chapter...

33
Chapter 2: Data Representation 2-1 Chapter 2: Data Representation

Upload: truongkhanh

Post on 19-Apr-2018

247 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-1

Chapter 2: Data Representation

Page 2: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-2

Chapter Contents2.1 Introduction2.2 Fixed Point Numbers2.3 Floating Point Numbers2.4 Case Study: Patriot Missile Defense Failure Caused by Loss of

Precision2.5 Character Codes

Page 3: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-3

Fixed Point Numbers• Using only two digits of precision for signed base 10 numbers,

the range (interval between lowest and highest numbers) is[-99, +99] and the precision (distance between successive num-bers) is 1.

• The maximum error , which is the difference between the value of areal number and the closest representable numbe r, is 1/2 the pre-cision. For this case, the error is 1/2 × 1 = 0.5.

• If we choose a = 70, b = 40, and c = -30, then a + (b + c) = 80 (whichis correct) but (a + b) + c = -30 which is incorrect. The problem isthat (a + b) is + 110 for this example, which exceeds the range of+99, and so only the rightmost two digits (+10) are retained in theintermediate result. This is a problem that we need to keep inmind when representing real numbers in a finite representation.

Page 4: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-4

Weighted Position Code• The base, or radix of a number system defines the range of pos-

sible values that a digit may have: 0 – 9 for decimal; 0,1 for binar y.

• The general form for determining the decimal value of a number isgiven by:

Example:

541.2510 = 5 × 102 + 4 × 101 + 1 × 100 + 2 × 10-1 + 5 × 10-2

= (500)10 + (40)10 + (1)10 + (2/10)10 + (5/100)10

= (541.25)10

Page 5: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-5

Base Conversion with the RemainderMethod

• Example: Convert 23.375 10 to base 2. Start by converting the inte-ger portion:

23/2 = 11 R 1

11/2 = 5 R 1

5/2 = 2 R 1

2/2 = 1 R 0

1/2 = 0 R 1

Integer Remainder

Least significant bit

Most significant bit

(23)10 = (10111)2

Page 6: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-6

Base Conversion with the Multiplica-tion Method

• Now, convert the fraction:

.375 × 2 = 0.75

.75 × 2 = 1.50

.5 × 2 = 1.00

Least significant bit

Most significant bit

(.375)10 = (.011)2

• Putting it all togethe r, 23.37510 = 10111.0112.

Page 7: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-7

Nonterminating Base 2 Fraction• We can’t always convert a terminating base 10 fraction into an

equivalent terminating base 2 fraction:

.2

.4

.8

.6

.2

.

.

.

0.4

0.8

1.6

1.2

0.4

=

=

=

=

=

2

2

2

2

2

×

×

×

×

×

Page 8: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-8

Base 2, 8, 10, 16 Number Systems

• Example: Show a column for ternary (base 3) . As an extension ofthat, convert 14 10 to base 3, using 3 as the divisor for the remain-der method (instead of 2). Result is 1123

Binary(base 2)

01

1011

100101110111

10001001101010111100110111101111

Octal(base 8)

01234567

1011121314151617

Decimal(base 10)

0123456789

101112131415

Hexadecimal(base 16)

0123456789ABCDEF

Page 9: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-9

More on Base Conversions• Converting among power-of-2 bases is particularly simple:

10112 = (102)(112) = 234

234 = (24)(34) = (102)(112) = 10112

1010102 = (1012)(0102) = 528

011011012 = (01102)(11012) = 6D16

• How many bits should be used for each base 4, 8, etc. , digit? Forbase 2, in which 2 = 2 1, the exponent is 1 and so one bit is usedfor each base 2 digit. For base 4, in which 4 = 2 2, the exponent is2, so so two bits are used for each base 4 digit. Likewise, for base8 and base 16, 8 = 2 3 and 16 = 24, and so 3 bits and 4 bits are usedfor base 8 and base 16 digits, respectivel y.

Page 10: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-10

Binary Addition• This simple binary addition example provides background for the

signed number representations to follo w.

Operands0

0+

00

SumCarry out

Carry in 0

0

1+

10

0

1

0+

10

0

1

1+

01

0

Example:

Carry

Addend: A

Augend: B

Sum

0 1 1 1 1 1 0 0

0 1 0 1 1 0 1 0

1 1 1 1 0 0 0 0

1 1 0 1 0 1 1 0

+

(124)10

(90)10

(214)10

0

0+

10

1

0

1+

01

1

1

0+

01

1

1

1+

11

1

Page 11: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-11

Signed Fixed Point Numbers• For an 8-bit numbe r, there are 2 8 = 256 possible bit patterns.

These bit patterns can represent negative numbers if we chooseto assign bit patterns to numbers in this wa y. We can assign halfof the bit patterns to negative numbers and half of the bit patternsto positive numbers.

• Four signed representations we will cover are:

Signed Magnitude

One’s Complement

Two’ s Complement

Excess (Biased)

Page 12: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-12

Signed Magnitude• Also know as “sign and magnitude,” the leftmost bit is the sign (0

= positive, 1 = negative) and the remaining bits are the magnitude.

• Example:

+2510 = 000110012

-2510 = 100110012

• Two representations for zero: +0 = 00000000 2, -0 = 100000002.

• Largest number is +127, smallest number is -127 10, using an 8-bitrepresentation.

Page 13: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-13

One’s Complement• The leftmost bit is the sign (0 = positive, 1 = negative). Negative of

a number is obtained by subtracting each bit from 2 (essentiall y,complementing each bit from 0 to 1 or from 1 to 0). This goes bothways: converting positive numbers to negative numbers, and con-verting negative numbers to positive numbers.

• Example:

+2510 = 000110012

-2510 = 111001102

• Two representations for zero: +0 = 00000000 2, -0 = 111111112.

• Largest number is +127 10, smallest number is -127 10, using an 8-bit representation.

Page 14: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-14

Two’s Complement• The leftmost bit is the sign (0 = positive, 1 = negative). Negative of

a number is obtained by adding 1 to the one ’s complement nega-tive. This goes both ways, converting between positive and nega-tive numbers.

• Exampl e (recall that -25 10 in one ’s complement is 111001102):

+2510 = 000110012

-2510 = 111001112

• One representation for zero: +0 = 00000000 2, -0 = 000000002.

• Largest number is +127 10, smallest number is -128 10, using an 8-bit representation.

Page 15: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-15

Excess (Biased)• The leftmost bit is the sign (usually 1 = positive, 0 = negative).

Positive and negative representations of a number are obtainedby adding a bias to the two ’s complement representation. Thisgoes both ways, converting between positive and negative num-bers. The effect is that numerically smaller numbers have smallerbit patterns, simplifying comparisons for floating point exponents.

• Exampl e (excess 128 “adds” 128 to the two ’s complement ver-sion, ignoring any carry out of the most significant bit ) :

+1210 = 100011002

-1210 = 011101002

• One representation for zero: +0 = 10000000 2, -0 = 100000002.

• Largest number is +127 10, smallest number is -128 10, using an 8-bit representation.

Page 16: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-16

BCD Representations in Nine ’s andTen’s Complement

• Each binary coded decimal digit is composed of 4 bits.0 0 0 0

(0)10

0 0 1 1

(3)10

0 0 0 0

(0)10

0 0 0 1

(1)10

(+301)10

1 0 0 1

(9)10

0 1 1 0

(6)10

1 0 0 1

(9)10

1 0 0 0

(8)10

(–301)10

1 0 0 1

(9)10

0 1 1 0

(6)10

1 0 0 1

(9)10

1 0 0 1

(9)10

(–301)10

Nine’s complement

Ten’s complement

Nine’s and ten’s complement

(a)

(b)

(c)

• Example: Represent +079 10 in BCD: 0000 0 111 1001

• Example: Represent -079 10 in BCD: 1001 0010 0001. This is ob-tained by first subtracting each digit of 079 from 9 to obtain thenine ’s complement, so 999 - 079 = 920 . Adding 1 produces theten’s complement: 920 + 1 = 921. Converting each base 10 digit of921 to BCD produces 1001 0010 0001.

Page 17: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-17

3-Bit Signed Integer Representations

Page 18: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-18

Base 10 Floating Point Numbers• Floating point numbers allow very large and very small numbers

to be represented using only a few digits, at the expense of preci-sion. The precision is primarily determined by the number of dig-its in the fraction (or significand , which has integer and fractionalparts), and the range is primarily determined by the number ofdigits in the exponent.

• Example (+6.02 3 × 1023):

+

Sign

2 3 6 0 2

Exponent(two digits)

Significand (four digits)

Position of decimal point

3.

Page 19: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-19

Normalization• The base 10 number 254 can be represented in floating point form

as 254 × 100, or equivalently as:

25.4 × 101, or

2.54 × 102, or

.254 × 103, or

.0254 × 104, or

infinitely many other ways, which creates problems when makingcomparisons, with so many representations of the same numbe r.

• Floating point numbers are usually normalized , in which the radixpoint is located in only one possible position for a given numbe r.

• Usuall y, but not always, the normalized representation places theradix point immediately to the left of the leftmost, nonzero digit inthe fraction, as in: .25 4 × 103.

Page 20: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-20

Floating Point Example• Represent .254 × 103 in a normalized base 8 floating point format

with a sign bit, followed by a 3-bit excess 4 exponent, followed byfour base 8 digits.

• Step #1: Convert to the target base.

.254 × 103 = 25410. Using the remainder method, we find that 254 10= 376 × 80:

254/8 = 31 R 6

31/8 = 3 R 7

3/8 = 0 R 3

• Step #2: Normalize: 37 6 × 80 = .376 × 83.

• Step #3: Fill in the bit fields, with a positive sign (sign bit = 0), anexponent of 3 + 4 = 7 (excess 4), and 4-digit fraction = .3760:

0 111 . 011 111 110 000

Page 21: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-21

Erro r, Range, and Precision• In the previous example, we have the base b = 8, the number of

significant digits (not bits!) in the fraction s = 4, the largest expo-nent value (not bit pattern) M = 3, and the smallest exponent valuem = -4.

• In the previous example, there is no explicit representation of 0,but there needs to be a special bit pattern reserved for 0 other-wise there would be no way to represent 0 without violating thenormalization rule. We will assume a bit pattern of0 000 000 000 000 000 represents 0.

• Using b, s, M, and m, we would like to characterize this floatingpoint representation in terms of the largest positive representablenumbe r, the smallest (nonzero) positive representable numbe r,the smallest gap between two successive numbers, the largestgap between two successive numbers, and the total number ofnumbers that can be represented.

Page 22: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-22

Erro r, Range, and Precision (cont’)

• Largest representable number: bM × (1 - b-s) = 83 × (1 - 8-4)

• Smallest representable number: bm × b-1 = 8-4 - 1 = 8-5

• Largest gap: bM × b-s = 83 - 4 = 8-1

• Smallest gap: bm × b-s = 8-4 - 4= 8-8

Page 23: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-23

Erro r, Range, and Precision (cont’)

• Number of representable numbers: There are 5 components: (A)sign bit; for each number except 0 for this case, there is both apositive and negative version; (B) ( M - m) + 1 exponents; (C) b - 1values for the first digit (0 is disallowed for the first normalizeddigit); (D) bs-1 values for each of the s-1 remaining digits, plus (E)a special representation for 0. For this example, the 5 componentsresult in: 2 × ((3 - 4) + 1) × (8 - 1) × 84-1 + 1 numbers that can berepresented. Notice this number must be no greater than the num-ber of possible bit patterns that can be generated, which is 2 16.

2 × ((M - m) + 1) × (b - 1) × bs-1 +

Sign bitFirst digit of fraction

Remaining digits of fraction

The number of exponents Zero

A EB C D

1

Page 24: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-24

Example Floating Point Format

• Smallest number is 1/8

• Largest number is 7/4

• Smallest gap is 1/32

• Largest gap is 1/4

• Number of representable numbers is 33.

–3 –1 –1 0 1 1 3– 1

414

– 18

18

22 2 2

b = 2 M = +1s = 3 m = –2

Page 25: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-25

Gap Size Follows Exponent Size• The relative error is approximately the same for all numbers.

• If we take the ratio of a large gap to a large numbe r, and comparethat to the ratio of a small gap to a small numbe r, then the ratiosare the same:

bM × (1 – b– s)

bM– s

1 – b– s

b– s

= =bs–1A large number

A large gap 1

bm × (1 – b– s)

bm– s

1 – b– s

b– s

= =bs–1A small number

A small gap 1

Page 26: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-26

Conversion Example• Example: Convert (9.375 × 10-2)10 to base 2 scientific notation

• Start by converting from base 10 floating point to base 10 fixedpoint by moving the decimal point two positions to the left, whichcorresponds to the -2 exponent: .09375.

• Next, convert from base 10 fixed point to base 2 fixed point:

.09375 × 2 = 0.1875

.1875 × 2 = 0.375

.375 × 2 = 0.75

.75 × 2 = 1.5

.5 × 2 = 1.0

• Thus, (.09375) 10 = (.00011)2.

• Finall y, convert to normalized base 2 floating point:

.00011 = .00011 × 20 = 1.1 × 2-4

Page 27: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-27

IEEE-754 Floating Point Formats

Single precision

Sign (1 bit)

Exponent Fraction

8 bits 23 bits

Double precision

Exponent Fraction

11 bits 52 bits

32 bits

64 bits

Page 28: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-28

IEEE-754 Examples

(a) +1.101 × 25

Value

0

Sign Exponent Fraction

Bit Pattern

1000 0100 101 0000 0000 0000 0000 0000

(b) −1.01011 × 2−126 1 0000 0001 010 1100 0000 0000 0000 0000

(c) +1.0 × 2127 0 1111 1110 000 0000 0000 0000 0000 0000

(d) +0 0 0000 0000 000 0000 0000 0000 0000 0000

(e) −0 1 0000 0000 000 0000 0000 0000 0000 0000

(f) +∞ 0 1111 1111 000 0000 0000 0000 0000 0000

(g) +2−128 0 0000 0000 010 0000 0000 0000 0000 0000

(h) +NaN 0 1111 1111 011 0111 0000 0000 0000 0000

(i) +2−128 0 011 0111 1111 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000

Page 29: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-29

IEEE-754 Conversion Example• Represent -12.625 10 in single precision IEEE-754 format.

• Step #1: Convert to target base. -12.625 10 = -1100.1012

• Step #2: Normalize. - 1100.1012 = -1.1001012 × 23

• Step #3: Fill in bit fields. Sign is negative, so sign bit is 1. Expo-nent is in excess 127 (not excess 128!), so exponent is repre-sented as the unsigned integer 3 + 127 = 130. Leading 1 ofsignificand is hidden, so final bit pattern is:

1 1000 0010 . 1001 0100 0000 0000 0000 000

Page 30: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-30

Effect of Loss of Precision• According to

the Genera l Ac-counting Officeof the U.S. Gov-ernment, a lossof precision inconverting 24-bit integers into24-bit floatingpoint numberswas responsiblefor the failure ofa Patriot anti-missile batter y.

Range Gate Area

Missile

Search action locates missile somewhere within beam

Validation action

Missile outside of range gate

Patriot Radar System

Page 31: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-31

ASCII Character Code• ASCII is a 7-bit code, com-

monly stored in 8-bitbytes.

• “A” is at 41 16. To convertupper case letters tolower case letters, add2016. Thus “a” is at 41 16 +2016 = 6116.

• The character “5” at posi-tion 35 16 is different thanthe number 5. To convertcharacter-numbers intonumber-numbers, sub-tract 30 16: 3516 - 3016 = 5.

00 NUL01 SOH02 STX03 ETX04 EOT05 ENQ06 ACK07 BEL08 BS09 HT0A LF0B VT0C FF0D CR0E SO0F SI

10 DLE11 DC112 DC213 DC314 DC415 NAK16 SYN17 ETB18 CAN19 EM1A SUB1B ESC1C FS1D GS1E RS1F US

20 SP21 !22 "23 #24 $25 %26 &27 '28 (29 )2A *2B +2C ´ 2D -2E .2F /

30 031 132 233 334 435 536 637 738 839 93A :3B ;3C <3D =3E >3F ?

40 @41 A42 B43 C44 D45 E46 F47 G48 H49 I4A J4B K4C L4D M4E N4F O

50 P51 Q52 R53 S54 T55 U56 V57 W58 X59 Y5A Z5B [5C \5D ]5E ^5F _

60 `61 a62 b63 c64 d65 e66 f67 g68 h69 i6A j6B k6C l6D m6E n6F o

70 p71 q72 r73 s74 t75 u76 v77 w78 x79 y7A z7B {7C |7D }7E ~7F DEL

NULSOHSTXETXEOTENQACKBEL

NullStart of headingStart of textEnd of textEnd of transmissionEnquiryAcknowledgeBell

BSHTLFVT

BackspaceHorizontal tabLine feedVertical tab

FFCRSOSIDLEDC1DC2DC3DC4NAKSYNETB

Form feedCarriage returnShift outShift inData link escapeDevice control 1Device control 2Device control 3Device control 4Negative acknowledgeSynchronous idleEnd of transmission block

CANEMSUBESCFSGSRSUSSPDEL

CancelEnd of mediumSubstituteEscapeFile separatorGroup separatorRecord separatorUnit separatorSpaceDelete

Page 32: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-32

EBCDICCharacter

Code• EBCDIC is an 8-bit

code.

STX Start of text RS Reader Stop DC1 Device Control 1 BEL BellDLE Data Link Escape PF Punch Off DC2 Device Control 2 SP SpaceBS Backspace DS Digit Select DC4 Device Control 4 IL IdleACK Acknowledge PN Punch On CU1 Customer Use 1 NUL NullSOH Start of Heading SM Set Mode CU2 Customer Use 2ENQ Enquiry LC Lower Case CU3 Customer Use 3ESC Escape CC Cursor Control SYN Synchronous IdleBYP Bypass CR Carriage Return IFS Interchange File SeparatorCAN Cancel EM End of Medium EOT End of TransmissionRES Restore FF Form Feed ETB End of Transmission BlockSI Shift In TM Tape Mark NAK Negative AcknowledgeSO Shift Out UC Upper Case SMM Start of Manual MessageDEL Delete FS Field Separator SOS Start of SignificanceSUB Substitute HT Horizontal Tab IGS Interchange Group SeparatorNL New Line VT Vertical Tab IRS Interchange Record SeparatorLF Line Feed UC Upper Case IUS Interchange Unit Separator

00 NUL 20 DS 40 SP 60 – 80 A0 C0 { E0 \01 SOH 21 SOS 41 61 / 81 a A1 ~ C1 A E1 02 STX 22 FS 42 62 82 b A2 s C2 B E2 S03 ETX 23 43 63 83 c A3 t C3 C E3 T04 PF 24 BYP 44 64 84 d A4 u C4 D E4 U05 HT 25 LF 45 65 85 e A5 v C5 E E5 V06 LC 26 ETB 46 66 86 f A6 w C6 F E6 W07 DEL 27 ESC 47 67 87 g A7 x C7 G E7 X08 28 48 68 88 h A8 y C8 H E8 Y09 29 49 69 89 i A9 z C9 I E9 Z0A SMM 2A SM 4A ¢ 6A ‘ 8A AA CA EA 0B VT 2B CU2 4B 6B , 8B AB CB EB 0C FF 2C 4C < 6C % 8C AC CC EC 0D CR 2D ENQ 4D ( 6D _ 8D AD CD ED 0E SO 2E ACK 4E + 6E > 8E AE CE EE 0F SI 2F BEL 4F | 6F ? 8F AF CF EF 10 DLE 30 50 & 70 90 B0 D0 } F0 011 DC1 31 51 71 91 j B1 D1 J F1 112 DC2 32 SYN 52 72 92 k B2 D2 K F2 213 TM 33 53 73 93 l B3 D3 L F3 314 RES 34 PN 54 74 94 m B4 D4 M F4 415 NL 35 RS 55 75 95 n B5 D5 N F5 516 BS 36 UC 56 76 96 o B6 D6 O F6 617 IL 37 EOT 57 77 97 p B7 D7 P F7 718 CAN 38 58 78 98 q B8 D8 Q F8 819 EM 39 59 79 99 r B9 D9 R F9 91A CC 3A 5A ! 7A : 9A BA DA FA | 1B CU1 3B CU3 5B $ 7B # 9B BB DB FB 1C IFS 3C DC4 5C . 7C @ 9C BC DC FC 1D IGS 3D NAK 5D ) 7D ' 9D BD DD FD 1E IRS 3E 5E ; 7E = 9E BE DE FE 1F IUS 3F SUB 5F ¬ 7F " 9F BF DF FF

Page 33: Chapter 2: Data Representation - radford.edumhtay/CPSC352/Lecture_PDF/Ch02POCA.pdf · 2-5 Chapter 2: Data Representation Base Conversion with the Remainder Method • Example: Convert

Chapter 2: Data Representatio n2-33

UnicodeCharacter

Code

• Unicode is a 16-bit code.

0000000100020003000400050006000700080009000A000B000C000D000E000F0010001100120013001400150016001700180019001A001B001C001D001E001F

NULSTXETX

Start of textEnd of text

ENQACKBEL

EnquiryAcknowledgeBell

BSHTLF

BackspaceHorizontal tabLine feed VT Vertical tab

SOH Start of headingEOT End of transmission

DLE Data link escape

DC1DC2DC3DC4NAKNBSETB

Device control 1Device control 2Device control 3Device control 4Negative acknowledgeNon-breaking spaceEnd of transmission block

EMSUBESCFSGSRSUS

End of mediumSubstituteEscapeFile separatorGroup separatorRecord separatorUnit separator

Null CAN Cancel

NUL 0020SOH 0021STX 0022ETX 0023EOT 0024ENQ 0025ACK 0026BEL 0027

00280029

LF 002AVT 002BFF 002CCR 002DSO 002ESI 002FDLE 0030DC1 0031DC2 0032DC3 0033DC4 0034NAK 0035SYN 0036ETB 0037CAN 0038EM 0039SUB 003AESC 003BFS 003CGS 003DRS 003EUS 003F

BSHT

0040004100420043004400450046004700480049004A004B004C004D004E004F0050005100520053005400550056005700580059005A005B005C005D005E005F

SP!"#$%&'()*+´ -./0123456789:;<=>?

0060006100620063006400650066006700680069006A006B006C006D006E006F0070007100720073007400750076007700780079007A007B007C007D007E007F

@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_

0080008100820083008400850086008700880089008A008B008C008D008E008F0090009100920093009400950096009700980099009A009B009C009D009E009F

`abcdefghijklmnopqrstuvwxyz{|}~

DEL

00A000A100A200A300A400A500A600A700A800A900AA00AB00AC00AD00AE00AF00B000B100B200B300B400B500B600B700B800B900BA00BB00BC00BD00BE00BF

CtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrlCtrl

00C000C100C200C300C400C500C600C700C800C900CA00CB00CC00CD00CE00CF00D000D100D200D300D400D500D600D700D800D900DA00DB00DC00DD00DE00DF

NBS¡ ¢ £ ¤ ¥

§ ¨ © a

« ¬ – ® –

˚ ± 2

3

´ µ ¶ ˙

1

o

» 1/41/23/4¿

Ç

00E000E100E200E300E400E500E600E700E800E900EA00EB00EC00ED00EE00EF00F000F100F200F300F400F500F600F700F800F900FA00FB00FC00FD00FE00FF

À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï

Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Yy

D

´ ´

à á â ã ä å æ ç è é ê ë ì í î ï

ñ ò ó ô õ ö ÷ ø ù ú û ü

ÿ

PP

pp

CR Carriage returnSO Shift outSI Shift in

FF Form feed

SPDEL

SpaceDelete

Ctrl Control

SYN Synchronous idle

§