8/9/2019 Section1 Nore
1/44
CS E1: Section 1:Counting in Binary
8/9/2019 Section1 Nore
2/44
8/9/2019 Section1 Nore
3/44
George Boole (1815-1864)
English mathematician Invented boolean logic
8/9/2019 Section1 Nore
4/44
George Boole (1815-1864)
English mathematician Invented boolean logic
Boolean Logic is everywhere boolean tools are built into search engines:
Boston Public Library Google Gmail
8/9/2019 Section1 Nore
5/44
George Boole (1815-1864)
English mathematician Invented boolean logic
Boolean Logic is everywhere lets you search for
Boston Public Library sharks NOT attack
Gmail
8/9/2019 Section1 Nore
6/44
George Boole (1815-1864)
English mathematician Invented boolean logic
Boolean Logic is everywhere lets you search for
Boston Public Library sharks NOT attack
"David Malan" AND "Dan Armendariz" Gmail
8/9/2019 Section1 Nore
7/44
George Boole (1815-1864)
English mathematician Invented boolean logic
Boolean Logic is everywhere lets you search for
Boston Public Library sharks NOT attack
"David Malan" AND "Dan Armendariz" Gmail from:[email protected] OR from:
8/9/2019 Section1 Nore
8/44
Claude Shannon (1916-2001)
American Mathematician Founded circuit design at 21 with his
Master's thesis at MIT Called the "most important master's thesis
of all time"
8/9/2019 Section1 Nore
9/44
Claude Shannon (1916-2001)
American Mathematician Founded circuit design at 21 with his
Master's thesis at MIT Called the "most important master's thesis
of all time"
The thesis describes how Boolean logiccircuits can represent any logical ornumerical relationship
8/9/2019 Section1 Nore
10/44
Claude Shannon (1916-2001)
American Mathematician Founded circuit design at 21 with his
Master's thesis at MIT Called the "most important master's thesis
of all time"
The thesis describes how Boolean logiccircuits can represent any logical ornumerical relationship
(wow - that's what makes computerspossible)
8/9/2019 Section1 Nore
11/44
What is a function?
A function is ...
8/9/2019 Section1 Nore
12/44
What is a function?
A function is ...
like a "machine" that turns inputs into an output
8/9/2019 Section1 Nore
13/44
What is a function?
A function is ...
like a "machine" that turns inputs into an output like a "black box" - to use it we don't need to know how it
works, we just need to know what it needs (inputs) and whatit does (output)
8/9/2019 Section1 Nore
14/44
What is a function?
For our purposes, a function is ...
like a "machine" that turns inputs into an output like a "black box" - to use it we don't need to know how it
works, we just need to know what it needs (inputs) and whatit does (output)
repeatable. The same inputs lead to the same output.
8/9/2019 Section1 Nore
15/44Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs, Chapter 1: Boolean Logic slide 10
a b out
0 0 0
0 1 0
1 0 01 1 1
How do we describe a function? With a truth table.
a and b are inputs of function"out" is the output of the function
http://www.idc.ac.il/tecs8/9/2019 Section1 Nore
16/44Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs, Chapter 1: Boolean Logic slide 10
What is the truth table of the "NOT" function?
How many inputs does it have?
NOT
http://www.idc.ac.il/tecs8/9/2019 Section1 Nore
17/44Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs, Chapter 1: Boolean Logic slide 10
a
0
1
What is the truth table of the "NOT" function?
How many inputs does it have?
ONEHow many outputs does it have?
NOT
http://www.idc.ac.il/tecs8/9/2019 Section1 Nore
18/44Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs, Chapter 1: Boolean Logic slide 10
a out
0
1
What is the truth table of the "NOT" function?
How many inputs does it have?
ONEHow many outputs does it have?
ONE
What is the relationship betweenthem?
NOT
http://www.idc.ac.il/tecs8/9/2019 Section1 Nore
19/44Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs, Chapter 1: Boolean Logic slide 10
a out
0 1
1 0
What is the truth table of the "NOT" function?
How many inputs does it have?
ONEHow many outputs does it have?
ONE
What is the relationship betweenthem?
OPPOSITE
NOT
http://www.idc.ac.il/tecs8/9/2019 Section1 Nore
20/44
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs, Chapter 1: Boolean Logic slide 10
a b out
0 0
0 1
1 01 1
What is the truth table of the "OR" function?
How many inputs does it have?
TWOHow many outputs does it have?
ONE
What is the relationship betweenthem?
OR
http://www.idc.ac.il/tecs8/9/2019 Section1 Nore
21/44
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs, Chapter 1: Boolean Logic slide 10
a b out
0 0 0
0 1
1 01 1
What is the truth table of the "OR" function?
How many inputs does it have?
TWOHow many outputs does it have?
ONE
What is the relationship betweenthem?
OR
http://www.idc.ac.il/tecs8/9/2019 Section1 Nore
22/44
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs, Chapter 1: Boolean Logic slide 10
a b out
0 0 0
0 1 1
1 01 1
What is the truth table of the "OR" function?
How many inputs does it have?
TWOHow many outputs does it have?
ONE
What is the relationship betweenthem?
OR
http://www.idc.ac.il/tecs8/9/2019 Section1 Nore
23/44
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs, Chapter 1: Boolean Logic slide 10
a b out
0 0 0
0 1 1
1 0 11 1
What is the truth table of the "OR" function?
How many inputs does it have?
TWOHow many outputs does it have?
ONE
What is the relationship betweenthem?
OR
http://www.idc.ac.il/tecs8/9/2019 Section1 Nore
24/44
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs, Chapter 1: Boolean Logic slide 10
a b out
0 0 0
0 1 1
1 0 11 1 1
What is the truth table of the "OR" function?
How many inputs does it have?
TWOHow many outputs does it have?
ONE
What is the relationship betweenthem?
OR
http://www.idc.ac.il/tecs8/9/2019 Section1 Nore
25/44
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs, Chapter 1: Boolean Logic slide 10
a b out
0 0 0
0 1 1
1 0 11 1 1
What is the truth table of the "OR" function?
How many inputs does it have?
TWOHow many outputs does it have?
ONE
What is the relationship betweenthem?
TRUE IF EITHER ORBOTH ARE TRUE,
FALSE OTHERWISE
OR
http://www.idc.ac.il/tecs8/9/2019 Section1 Nore
26/44
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs, Chapter 1: Boolean Logic slide 3
All Boolean functions of 2 variables
http://www.idc.ac.il/tecs8/9/2019 Section1 Nore
27/44
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs, Chapter 1: Boolean Logic slide 3
All Boolean functions of 2 variables
What do you notice aboutthe pattern?
http://www.idc.ac.il/tecs8/9/2019 Section1 Nore
28/44
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs, Chapter 1: Boolean Logic slide 5
Gate logic - each function has its own "chip" inside the cpu
Gate logic a gate architecture designed to implement a Boolean function
Elementary gates:
Composite gates:
Important distinction: Interface (what) VS implementation (how).
http://www.idc.ac.il/tecs8/9/2019 Section1 Nore
29/44
CS E1, Section 1:number vocabularybit, byte, kilo-, mega-, giga-, tera-
8/9/2019 Section1 Nore
30/44
Vocab
BIT
8/9/2019 Section1 Nore
31/44
Vocab
BIT a one or a zero
8/9/2019 Section1 Nore
32/44
Vocab
BIT a one or a zero
BYTE
8/9/2019 Section1 Nore
33/44
Vocab
BIT a one or a zero
BYTE eight bits: 0 0 0 0 0 0 0 0
8/9/2019 Section1 Nore
34/44
Vocab
BIT a one or a zero
BYTE eight bits: 0 0 0 0 0 0 0 0
can store 2^8 numbers:
8/9/2019 Section1 Nore
35/44
Vocab
BIT a one or a zero
BYTE eight bits: 0 0 0 0 0 0 0 0
can store 2^8 numbers: 0-255 KILOBYTE
8/9/2019 Section1 Nore
36/44
Vocab
BIT a one or a zero
BYTE eight bits: 0 0 0 0 0 0 0 0
can store 2^8 numbers: 0-255 KILOBYTE
~1000 bytes
8/9/2019 Section1 Nore
37/44
Vocab
BIT a one or a zero
BYTE eight bits: 0 0 0 0 0 0 0 0
can store 2^8 numbers: 0-255 stores one character
KILOBYTE ~1000 bytes actually 2^10 numbers: 0-1023
stores less than eight twitter posts
8/9/2019 Section1 Nore
38/44
Vocab
BIT a one or a zero
BYTE eight bits: 0 0 0 0 0 0 0 0
can store 2^8 numbers: 0-255 stores one character
KILOBYTE ~1000 bytes actually 2^10 numbers: 0-1023
stores less than eight twitter posts MEGABYTE
~1,000,000 bytes actually 2^30 numbers: 0-1,048,575 - less than 1/3 of
a typical mp3 song
8/9/2019 Section1 Nore
39/44
Vocab
http://en.wikipedia.org/wiki/Megabyte
http://en.wikipedia.org/wiki/Megabyte8/9/2019 Section1 Nore
40/44
CS E1, Section 1:asciiAmerican Standard Code for Information
Interchange
8/9/2019 Section1 Nore
41/44
CS E1, Section 1: ascii
8/9/2019 Section1 Nore
42/44
Ascii numbers to remember:
65 is capital 'A'97 is lowercase 'a'
8/9/2019 Section1 Nore
43/44
Source, explanation: link
http://www.hanselman.com/blog/WhyTheAskObamaTweetWasGarbledOnScreenKnowYourUTF8UnicodeASCIIAndANSIDecodingMrPresident.aspx8/9/2019 Section1 Nore
44/44
example: ascii in a spreadsheet
https://docs.google.com/spreadsheet/ccc?key=0ApKUsT5wTHHgdHpDNkEtOUlDUUNkeVF4cmlhSlVXYVE&
hl=en_US
https://docs.google.com/spreadsheet/ccc?key=0ApKUsT5wTHHgdHpDNkEtOUlDUUNkeVF4cmlhSlVXYVE&hl=en_UShttps://docs.google.com/spreadsheet/ccc?key=0ApKUsT5wTHHgdHpDNkEtOUlDUUNkeVF4cmlhSlVXYVE&hl=en_UShttps://docs.google.com/spreadsheet/ccc?key=0ApKUsT5wTHHgdHpDNkEtOUlDUUNkeVF4cmlhSlVXYVE&hl=en_UShttps://docs.google.com/spreadsheet/ccc?key=0ApKUsT5wTHHgdHpDNkEtOUlDUUNkeVF4cmlhSlVXYVE&hl=en_UShttps://docs.google.com/spreadsheet/ccc?key=0ApKUsT5wTHHgdHpDNkEtOUlDUUNkeVF4cmlhSlVXYVE&hl=en_US