150 likes | 264 Views
Representing Nonnumeric Data. Everything is really a number. Its all 1’s and 0’s. How do we represent other things? Words/Pictures/Sound? The trick is to come up with an encoding scheme…. Text. To store English we need Letters (upper case & lower) Punctuation
E N D
Representing Nonnumeric Data Everything is really a number
Its all 1’s and 0’s • How do we represent other things? • Words/Pictures/Sound? • The trick is to come up with an encoding scheme…
Text • To store English we need • Letters (upper case & lower) • Punctuation • Special marks (space, newline, etc…) • Assigned each a number between 0 and 127 • A is 65, B is 66… • a is 97, b is 98… • ASCII encoding : most popular such scheme
ASCII table • Partial table • Full Table:http://www.ascii-code.com/ • A = 65 = 01000001 • My name:
Text • Why 0-127? • Well it seemed like enough • 127 is 2^7 – the biggest number you can write with 7 binary digits. • Need more characters? • Extended ASCII – 8 bits (1 byte) – 256 characters • Make your own encoding scheme:http://en.wikipedia.org/wiki/Character_encoding • Unicode – universal scheme – up to 4 bytes per character
Basic Types of Graphics • Two basic types of 2D graphic Bitmap Vector
Bitmaps • Image divided into pixels • Each pixel either on (1) or off (0)
Adding gray • 2 digits for each square give 4 “colors” (00, 01, 10, 11)
Adding gray • 2 digits for each square give 4 “colors” (00, 01, 10, 11)
Vector Art • Vector images are mathematically based • Everything described as lines and curves • Shapes are filled with solid color, gradients or patterns
Computer Sounds • Two approaches to representing sound as numbers: • MIDI sequences • Samples
MIDI • Musical Instrument Digital Interface • Sheet music for your computer. • Does not store actual sounds – just instructions for generating the sounds. • Very compact • Been around since the 60’s
Samples • Sounds are just pressure waves:
Samples • Simulate a wave with lots of data points • Intensities at points in time • Computer reconstructs wave from points