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
Rational Numbers
The decimal point can "float" around
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
RGB Colors
Image Source: Wikipedia
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:
Binary Worksheet