representing nonnumeric data

14
Representing Nonnumeric Data Everything is really a number

Upload: abel-black

Post on 30-Dec-2015

22 views

Category:

Documents


2 download

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Representing Nonnumeric Data

Representing Nonnumeric Data

Everything is really a number

Page 2: Representing Nonnumeric Data

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…

Page 3: Representing Nonnumeric Data

Text

• To store English we need– Letters (upper case & lower)– Punctuation– Special marks (space, newline, etc…)

Page 4: Representing Nonnumeric Data

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

Page 5: Representing Nonnumeric Data

ASCII tableDEC OCT HEX BIN Symbol

47 057 2F 00101111 /

48 060 30 00110000 0

49 061 31 00110001 1

50 062 32 00110010 2

51 063 33 00110011 3

52 064 34 00110100 4

53 065 35 00110101 5

54 066 36 00110110 6

55 067 37 00110111 7

56 070 38 00111000 8

57 071 39 00111001 9

58 072 3A 00111010 :

59 073 3B 00111011 ;

60 074 3C 00111100 <

61 075 3D 00111101 =

62 076 3E 00111110 >

63 077 3F 00111111 ?

64 100 40 01000000 @

65 101 41 01000001 A

66 102 42 01000010 B

67 103 43 01000011 C

68 104 44 01000100 D

69 105 45 01000101 E

70 106 46 01000110 F

71 107 47 01000111 G

72 110 48 01001000 H

73 111 49 01001001 I

• Partial table • Full Table:

http://www.ascii-code.com/

• A = 65 = 01000001

• My name:A n d r e w

01000001 01101110 01100100 01110010 01100101 01110111

Page 6: Representing Nonnumeric Data

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 – Unicode – universal scheme – up to 4 bytes per character

http://unicode-table.com/en/#devanagari

Page 7: Representing Nonnumeric Data

Bitmaps

• Image divided into pixels– Each pixel either on (1) or off (0)

Page 8: Representing Nonnumeric Data

Adding gray

• 2 digits for each square give 4 “colors” (00, 01, 10, 11)

Page 9: Representing Nonnumeric Data

Adding gray

• 2 digits for each square give 4 “colors” (00, 01, 10, 11)

Page 10: Representing Nonnumeric Data

Image Size

Image is 2000 pixels wide & 1000 pixels tall.

2000 x 1000 = 2,000,000 pixels

Bits per Pixel 24 8 8 1

Number Colors 16,777,216 256 (color) 256 (grays) 2

Image Size 48,000,000 bitsor ~5.7 MBytes

16,000,000 bitsor ~1.9 MBytes

16,000,000 bitsor ~1.9 MBytes

2,000,000 bitsor ~244 KBytes

Page 11: Representing Nonnumeric Data

Vector Art

• Vector images are mathematically based– Everything described as lines and curves– Shapes are filled with solid color, gradients or patterns

Page 12: Representing Nonnumeric Data

Computer Sounds

• Two approaches to representing sound as numbers:– MIDI sequences– Samples

Page 13: Representing Nonnumeric Data

Samples

• Sounds are just pressure waves:

Page 14: Representing Nonnumeric Data

Samples

• Simulate a wave with lots of data points– Intensities at points in time– Computer reconstructs wave from points

011111

100000

000000