Computer Science 15-100 (Sections T & U), Spring 2008
Class Notes: Introduction
Logistics
- First Day
- Welcome and Introductions
- Waitlists: see me today
- Syllabus + Course Policies
- Reading:
- L&L Chapter 1 (Introduction)
- L&L Appendix B (Number Systems)
- L&L Appendix C (Unicode)
- Hw1: due Friday
- Quiz1: on Tuesday
Topic Outline:
- Programming vs Computer Science
- How to Read the Textbook
- The Digital in "Digital Computers"
- Represent everything as numbers
- Letters as numbers (Unicode: 'A' = 65, 'a' = 97, '0' = 48, 'space'
= 32)
- Pictures as numbers (pixels -> RGB)
- Sounds as numbers (see p 6; sampling rate, digitization, etc)
- Represent numbers in binary (base 2)
- Represent binary in physical transistors
- Thus: everything is a 1 or 0 (hence, digital)
- Analog vs. Digital
- Powers of 2
- 28 = 256 [ eg: IP addresses contain numbers
between 0 and 255; same often goes for RGB values... ]
- 210 =~ 1k
- 220 =~ 1m
- 230 =~ 1b
- So: 231 = 2*230 =~ 2b
- And: 232 = 22*230 =~ 4b
- Counting in Base 2, Base 10, and Base 16
- Converting between bases
- Two's Complement (or: How to represent negative numbers in
binary)
- Negate by flipping the bits (complementing) and adding one
- For example (in 4-bit two's complement):
To compute -6:
Start with +6 = 0110
Flip the bits: 1001
And add 1: 1010
= -6 Let's confirm this by
negating the negation:
Start with -6 = 1010
Flip the bits: 0101
And add 1: 0110
= +6 (It works!)
- Q: What does 1111 equal? How about 11111111...1111?
- Neat trick (and why we do this): subtraction by addition:
- For example (in 4-bit two's complement):
To add -6 and +7:
-6 = 1010
+7 = 0111
----
0001 = +1 (It
works!)
To add -6 and +3:
-6 = 1010
+3 = 0011
----
1101 = -3
(flip the bits --> 0010, add 1 --> 0011 = +3).
- So what?
Well, given that Java represents integers in 32-bit two's complement:
- The largest positive integer is (231 - 1) or about 2
billion.
- If we add one to that number, we get 231, which is the
smallest negative, or about negative 2 billion.
- Let's rephrase that:
If we start a counter in Java at 0 and keep adding 1 to it, soon after 2
billion we'll overflow and the counter will equal about -2 billion!
Wow!
- Some Units You Should Know
- Bit, Nybble, Byte
- Kilobit (Kb), Kilobyte (KB), Megabit (Mb), Megabyte (MB), Gigabit (Gb),
Gigabyte (GB), Terabit (Tb), Terabyte (TB)
- Hertz (Hz)
- Kilohertz (KHz) and millisecond (ms), Megahertz (MHz) and microsecond
(mu-s), Gigahertz (GHz) and nanosecond (ns)
- Note: Light travels about 1 foot in one billionth of a second (one
nanosecond)
- Note: Modems are 56 Kbps and not 56 KBps!
- Moore's Law:
- Roughly: for the same price, every 2 years computers are twice as
fast with twice the RAM, twice the storage, etc...
(or so said Intel co-founder Gordon Moore in 1965; he's been right for 43
years and counting!)
- See
http://en.wikipedia.org/wiki/Moore's_law.
Q: About how much faster will computers be in 10 years? 20
years? Roughly when will computers be 1 million times faster than
today?
carpe diem -
carpe diem - carpe diem - carpe diem
- carpe diem - carpe diem -
carpe diem - carpe diem - carpe
diem