CSE 111 Representing Nonnumeric Data in a Computer.
-
Upload
lynn-julia-mills -
Category
Documents
-
view
218 -
download
0
Transcript of CSE 111 Representing Nonnumeric Data in a Computer.
Text
American Code for Standard Information Interchange (ASCII)7-bitEnglishFor codes, see
http://www.asciitable.comhttp://en.wikipedia.org/wiki/File:ASCII_Code_Chart-Quick_ref_card.png
Examples1000001 represents A1001110 represents N1100001 represents a1110010 represents r
Images
A grid represents pixels in the imageThe color of each pixel can be black or whiteA bit represents the color of the pixel
Each bit can be a 0 (white) or a 1 (black)
ExampleConsider the following image
Images
Example Con’t.How many bits are required to render the letters UB
as an image? 9,350 bits
11 0
8 5
Images
ColorEach pixel is represented by multiple bits which
indicate how much of each color is needed to create the desired color
Examples
R ed G reen
Ye llo w (1 0 0 % R e d , 1 0 0 % G ree n , 5 0 % B lu e )O ran g e (1 0 0 % R e d , 4 0 % G reen )
L ig h t B lu e (6 0 % R e d , 6 0 % G ree n , 1 0 0 % B lu e )G rey (5 0 % R ed , 5 0 % B lu e , 5 0 % G ree n )
B ro w n (5 0 % R ed , 2 5 % G reen , 2 5 % B lu e )B lu e
P u rp le (5 0 % R ed , 5 0 % B lu e )
Images
ColorExample
Use 8-bits to represent redUse 8-bits to represent blueUse 8-bits to represent greenResult
Each pixel can take on 16,777,216 possible colors
Using this scheme, the previous example (UB) would require 224,400 bits 24-fold increase over black & white
Colors in Microsoft WindowsLowMediumHigh
Error Detection
A code is said to be n-error detecting if the minimum of n errors that cannot be detected is n+1Error defined as a bit being complemented
erroneously
Example2-out-of-5 codes
Single error detectingExample
A 01010 transmitted as 01110Error can be detected
Error Detection
ExampleParity
A parity bit can be concatenated to a code word that does not incorporate error detection to make it a single error detecting codeDetects an odd number of errors
Even ParityThe code word (including the parity bit) has an even number of
1’s
Odd ParityThe code word (including the parity bit) has an odd number of
1’s
ExampleThe 7-bit ASCII code is often concatenated with a parity bitH (odd parity) 11001000
Error Correction
It is possible to construct a code whereby a finite number of errors can be corrected
Error Correction
POSTNET ExampleUsed by US Postal Service to encode ZIP codesCheck Sum Digits for Error Correction2-out-of-5 code is used to encode each digitA checksum digit is appended to ZIP code so that
sum is a multiple of 10If a single digit is in error (number of 1’s 2) the
checksum can be used to correct check digit
Entire code is encapsulated between an initial and a guard bit (logic-1)
Z IP D ig it
S u m+
C h eck S u m
D igitm o d 1 0
0
Error Correction
POSTNET ExampleBarcode sprayed on deliverable mail for automated
mail processing
1234567890
Error Correction
POSTNET ExampleCurrently Used Formats
5 Digit ZIP CodeA Code
9 Digit ZIP and ZIP + 4 CodeC CodeAllows sorting to individual delivery carrier and in some cases,
sequencing
11 Delivery Point Bar Code (DPBC)Consists of 5 digit ZIP, ZIP + 4, and delivery point codeAllows sorting to delivery point (address) sequence
Error Correction
POSTNET ExampleZIP digits and checksum digit are encapsulated
between two one’sExample
1 7
4 2Z IP C o d e
6 0
Error Correction
Another POSTNET ExampleWhat ZIP Code is encoded by the following
POSTNET code?
196
Z IP C o d e? 0 9
Error Correction
Another POSTNET ExampleWhat ZIP Code is encoded by the following POSTNET
code?
Sum up known (error-free) ZIP digits1 + 6 + 0 + 9 = 16
Check digit9
Solve(16 + x + 9) mod 10 = 0
where x is the unknown digit
(16 + x + 9) = 30since x must be 0 x 9
x = 5
196
Z IP C o d e? 0 9
Z IP D ig it
S u m+
C h eck S u m
D igitm o d 1 0
0
Error Correction
Another POSTNET ExampleWhat ZIP Code is encoded by the following
POSTNET code?
196
Z IP C o d e5 0 9
Error Correction
Another POSTNET ExampleWhat check sum digit must be included in the
POSTNET encoding for the ZIP code 97121-1542?
Error Correction
Another POSTNET ExampleWhat check sum digit must be included in the
POSTNET encoding for the ZIP code 97121-1542?
Sum ZIP Digits9 + 7 + 1 + 2 + 1 + 1 + 5 + 4 + 2 = 32
Determine Check DigitLet x represent the check digit(32 + x) mod 10 = 0
(32 + x) = 40
since x must be 0 x 9x = 8
Z IP D ig it
S u m+
C h eck S u m
D igitm o d 1 0
0
References
J. Glenn Brookshear, Computer Science - An Overview, 11th edition, Addison-Wesley as an imprint of Pearson, 2012
W. Daniel Hillis, The Pattern on the Stone, Basic Books (Perseus Books Group), 1998
Donald D. Givone, Digital Principles and Design, McGraw-Hill, 2003
John L. Hennessy and David A. Patterson, Computer Organization and Design, The Hardware/Software Interface, 3rd Edition, Morgan Kaufmann Publishers, Inc., 2005
http://en.widipedia.org/wiki/Postnethttp://www.asciitable.comhttp://en.wikipedia.org/wiki/File:ASCII_Code_Chart-
Quick_ref_card.png