Your browser doesn't support the features required by impress.js, so you are presented with a simplified version of this presentation.

For the best experience please use the latest Chrome, Safari or Firefox browser.

CIS 115

Lecture 8: Encoding Data

George Boole

Image Source: Wikipedia

Gottfried Willhelm von Leibniz

Image Source: Wikipedia

Charles Babbage

Image Source: Wikipedia

Claude Shannon

Image Source: Wikipedia

George Stibitz

Image Source: Wikipedia

Complex Numerical Calculator

Image Source: Computer History Museum

Binary - Natural Numbers

128 64 32 16 8 4 2 1
0 0 1 0 1 0 1 0






0*128 0*64 1*32 0*16 1*8 0*4 1*2 0*1








32 + 8 + 2 = 42

Binary Data Types

Negative Numbers



0 0 1 0 1 0 1 0 42

Negative Numbers



0 0 1 0 1 0 1 0 42

1 1 0 1 0 1 0 1 -42

One's Compliment Addition

0 0 1 0 1 0 1 0 42

+

1 1 0 1 0 1 0 1 -42

=

One's Compliment Addition

0 0 1 0 1 0 1 0 42

+

1 1 0 1 0 1 0 1 -42

=

1 1 1 1 1 1 1 1 -0


Hmm, that's not quite right...

Negative Numbers


0 0 1 0 1 0 1 0 42

invert

1 1 0 1 0 1 0 1

Negative Numbers


0 0 1 0 1 0 1 0 42

invert

1 1 0 1 0 1 0 1

plus 1

1 1 0 1 0 1 1 0 -42

Two's Compliment Addition

0 0 1 0 1 0 1 0 42

+

1 1 0 1 0 1 1 0 -42

=

Two's Compliment Addition

0 0 1 0 1 0 1 0 42

+

1 1 0 1 0 1 1 0 -42

=

0 0 0 0 0 0 0 0 0


That works!

Other Values

Binary Unsigned Signed
00000000 0 0
00000001 1 1
00000010 2 2
01111110 126 126
01111111 127 127
10000000 128 -128
10000001 129 -127
10000010 130 -126
11111110 254 -2
11111111 255 -1

Range of Values

Floating Point

- Exponent Mantissa
0 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1

Floating Point Example

- Exponent Mantissa
0 1 0 1 0 0 0 1 0 1 0 0 0 0 0 0

Mantissa: (1).01010 = 1.3125
Exponent: 10100 - 01111 = 20 - 15 = 5

Floating Point Example

- Exponent Mantissa
0 1 0 1 0 0 0 1 0 1 0 0 0 0 0 0

Mantissa: (1).01010 = 1.3125
Exponent: 10100 - 01111 = 20 - 15 = 5
Value: 1.3125 * 25 = 42

1.01010 * 25 = 101010 = 42

Range of Values


Not exact, but not bad either

Real World

Text - ASCII

Image Source: ASCIItable.com

Text - ASCII

011001100110111101110010011101000111
100100100000011101000111011101101111

Text - ASCII

011001100110111101110010011101000111
100100100000011101000111011101101111

Text - ASCII

011001100110111101110010011101000111
100100100000011101000111011101101111

Images

Image Source: Wikipedia

Vector Graphics (SVG)

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="350pt" height="450pt" 
  viewBox="0 0 350 450" version="1.1" 
  xmlns="http://www.w3.org/2000/svg">
<path fill="#ffffff" d=" M 0.00 0.00 L 270.80 
   0.00 C 270.29 1.10 269.84 2.22 269.41 3.34 C 
  270.05 3.42 271.34 3.57 271.98 3.65 C 271.83 
  2.43 271.66 1.21 271.49 0.00 L 320.83 0.00 C 
  320.62 1.16 320.43 2.32 320.27 3.48 C 320.88 
  3.49 322.11 3.50 322.73 3.51 C 322.60 2.64 
  322.35 0.89 322.23 0.01....

RGB Colors

Image Source: Wikipedia

Compression

How much wood could
a woodchuck chuck if a
woodchuck could chuck wood?

Compression

How much wood could
a woodchuck chuck if a
woodchuck could chuck wood?


wood = 1      could = 2      chuck = 3

Compression

How much wood could
a woodchuck chuck if a
woodchuck could chuck wood?


wood = 1      could = 2      chuck = 3


How much 1 2 a 13 3 if a 13 2 3 1?

Image Compression

Image Source: D. Kriesel

Image Compression

Image Source: D. Kriesel

Image Source: D. Kriesel

Read more here

Assignments

Blog 3: Algorithms

Think about something that you do every day. That one thing probably is composed of many smaller steps, which you have to perform in the correct order. How would you describe those steps to someone unfamiliar with the action? How would you describe them to a robot that can follow your actions? While we may not think of it in this way very often, most of our daily lives could be expressed as an algorithm. Choose a few examples of actions you perform often, and write about how you would express them as algorithms. Some things to consider: