number representations what all the numbers can mean

14
Number Representations What all the numbers can mean.

Upload: nicholas-lawson

Post on 01-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Number Representations What all the numbers can mean

Number Representations

What all the numbers can mean.

Page 2: Number Representations What all the numbers can mean

General Idea

• In a computer, all information is binary numbers

• Those numbers have to be interpreted to become the information we want

• In other words, numbers can represent other things.

• Another way to think of Digital is “representable by numbers”

Page 3: Number Representations What all the numbers can mean

ASCII

American Standard Code for Information Interchange

cipher(code) to convert numbers to symbols

1 byte = letter of the alphabet or a symbol

when you type, the keyboard sends an ASCII byte to the PC

There are 256 possible characters (the number of numbers that can be represented by 1 byte)

Page 4: Number Representations What all the numbers can mean

ASCII examples

• ! = 51(33h)• A to Z = 65(41h) to 90(5Ah)• a to z = 97(61h) to 122(7Ah)

Page 5: Number Representations What all the numbers can mean

ASCII Exercise

• Hello!Letter H e l l o !

Hex 48h 65h 6Bh 6Bh 6Fh 33h

Bin 0100 1000

0110 0110

0110 1011

0110 1011

0110 1111

0011 0011

Page 6: Number Representations What all the numbers can mean

ASCII Weaknesses?

• Think about other languages – you can’t fit ALL those symbols into 256 characters

Page 7: Number Representations What all the numbers can mean

Unicode• Unicode (Also called UTF-8) allows up

to 4 byes to represent a single character

• How many different characters possible?

• 4,294,967,296 (232) in theory• 2,147,483,648 (231) in real life• still enough for every language on

earth (including fictional ones like Klingon and Elvish)

Page 8: Number Representations What all the numbers can mean

Other ways computers use numbers

• This means nothing to us:• 00000000000000000000000100100

00001001000000100100000000000000000000000001000010000011110000000000000

Page 9: Number Representations What all the numbers can mean

cont.

• But what about this?• 0000000000• 0000000000• 0001001000• 0001001000• 0001001000• 0000000000• 0010000100• 0001111000• 0000000000

• or this?

Page 10: Number Representations What all the numbers can mean

Bitmaps

• a computer interprets an image as a bitmap: a series of bits that represent pixels (picture elements)

• What about colors?

Page 11: Number Representations What all the numbers can mean

Colors• normally, one pixel is 3 bytes (24-

bits)• 1 byte for each primary color (RGB)• FF 00 00 is bright red• 00 FF FF is bright cyan (G & B)• 33 33 33 is dark grey• FF 00 FF is bright magenta (R & B)• So how many different colors are

there?

Page 12: Number Representations What all the numbers can mean

Understanding

• A megapixel is a million pixels. If the color is 24-bit, how many bytes is a megapixel? How many megabytes?

• Cameras are now commonly 5 megapixel (or more)

Page 13: Number Representations What all the numbers can mean

Cameras: Megapixel Myth1 MP(megapixel) = a million pixelsAn image 1000 pixels wide and 1000

pixels tall is a megapixel (1000x1000)So how wide and tall is a 2 MP image?1414x1414 (the SQUARE ROOT of 2

mil.)You’d need 4MP to double the image

quality (math: exponential relationship)So the quality difference between 7

and 8 MP is actually pretty small.DON’T pay the extra $100 for the extra

megapixel.

Page 14: Number Representations What all the numbers can mean

Final Point

• A computer sees a bunch of numbers and does math to them.

• What those numbers mean depend on the instructions given to the computer

• Are those 1s and 0s a picture? a document? music? It all depends on what we tell the computer to do with those bits.