220 likes | 238 Views
Explore ASCII and Unicode encoding, color representation, error detection, correction techniques like parity and POSTNET encoding. Learn about the utilization of bits in images and ZIP code correction.
E N D
CSE 111 Representing Nonnumeric Data in a Computer
Text • American Code for Standard Information Interchange (ASCII) • 7-bit • English • For codes, see • http://www.asciitable.com • http://en.wikipedia.org/wiki/File:ASCII_Code_Chart-Quick_ref_card.png • Examples • 1000001 represents A • 1001110 represents N • 1100001 represents a • 1110010 represents r
Text • Unicode • 16-bit • International • Windows • ASCII vs. Unicode • Advantages • Disadvantages
Images • A grid represents pixels in the image • The color of each pixel can be black or white • A bit represents the color of the pixel • Each bit can be a 0 (white) or a 1 (black) • Example • Consider the following image
Images • Example Con’t.
Images • Example Con’t. • How many bits are required to render the letters UB as an image? • 9,350 bits
Images • Color • Each pixel is represented by multiple bits which indicate how much of each color is needed to create the desired color • Examples
Images • Color • Example • Use 8-bits to represent red • Use 8-bits to represent blue • Use 8-bits to represent green • Result • 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 Windows • Low • Medium • High
Error Detection • A code is said to be n-error detecting if the minimum of n errors that cannot be detected is n+1 • Error defined as a bit being complemented erroneously • Example • 2-out-of-5 codes • Single error detecting • Example • A 01010 transmitted as 01110 • Error can be detected
Error Detection • Example • Parity • A parity bit can be concatenated to a code word that does not incorporate error detection to make it a single error detecting code • Detects an odd number of errors • Even Parity • The code word (including the parity bit) has an even number of 1’s • Odd Parity • The code word (including the parity bit) has an odd number of 1’s • Example • The 7-bit ASCII code is often concatenated with a parity bit • H (odd parity) 11001000
Error Correction • It is possible to construct a code whereby a finite number of errors can be corrected
Error Correction • POSTNET Example • Used by US Postal Service to encode ZIP codes • Check Sum Digits for Error Correction • 2-out-of-5 code is used to encode each digit • A checksum digit is appended to ZIP code so that sum is a multiple of 10 • If 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)
Error Correction • POSTNET Example • Barcode sprayed on deliverable mail for automated mail processing
Error Correction • POSTNET Example • Currently Used Formats • 5 Digit ZIP Code • A Code • 9 Digit ZIP and ZIP + 4 Code • C Code • Allows 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 code • Allows sorting to delivery point (address) sequence
Error Correction • POSTNET Example • ZIP digits and checksum digit are encapsulated between two one’s • Example
Error Correction • Another POSTNET Example • What ZIP Code is encoded by the following POSTNET code?
Error Correction • Another POSTNET Example • What ZIP Code is encoded by the following POSTNET code?
Error Correction • Another POSTNET Example • What ZIP Code is encoded by the following POSTNET code? • Sum up known (error-free) ZIP digits • 1 + 6 + 0 + 9 = 16 • Check digit • 9 • Solve • (16 + x + 9) mod 10 = 0 • where x is the unknown digit • (16 + x + 9) = 30 • since x must be 0 x 9 • x = 5
Error Correction • Another POSTNET Example • What ZIP Code is encoded by the following POSTNET code?
Error Correction • Another POSTNET Example • What check sum digit must be included in the POSTNET encoding for the ZIP code 97121-1542?
Error Correction • Another POSTNET Example • What check sum digit must be included in the POSTNET encoding for the ZIP code 97121-1542? • Sum ZIP Digits • 9 + 7 + 1 + 2 + 1 + 1 + 5 + 4 + 2 = 32 • Determine Check Digit • Let x represent the check digit • (32 + x) mod 10 = 0 • (32 + x) = 40 since x must be 0 x 9 • x = 8
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/Postnet • http://www.asciitable.com • http://en.wikipedia.org/wiki/File:ASCII_Code_Chart-Quick_ref_card.png