Goals
- Get your class account setup.
- Look at the internal representation of numbers and practice thinking in binary.
- Get to know your classmates and play games!
Reading
- P&H (4th or 5th): 2.4
Accounts
You need to have an EECS instructional account (cs61c-*) in order to do your lab work (and submit assignments).
Make sure to get an account form from your lab TA.
Most importantly, you will need to log in to this account in order to enroll in the class.
Don't forget to change your password once you have logged in!
Mini-Lecture
The first part of lab will be a mini-lecture given by your TA. Topics to be covered include:
- Basic number representation
- Binary, decimal, and hexadecimal
- IEC prefixes
- Exclusive OR (XOR)
Exercises
Exercise 0: Account Registration
Log in to your instructional account and run the register command, filling out the requested information. If you get an error message telling you to contact your TA for assistance, ssh into star.cs.berkeley.edu and try again (the hive machines have been finicky about registering students in the past). This exercise is of critical importance -- we won't be able to grade many of your assignments unless you are properly registered.
Checkoff:
Run check-register and show the results to your TA.Exercise 1: Binary Alphabet
Let's take 4-bit numbers. If we stack five 4-bit numbers on top of each other in binary, we can make patterns and pictures! To help visualize this, you can think of 0's and 1's as white and black instead. For example, what does the following bit pattern look like?
0 | 1 | 1 | 0 | □ | ■ | ■ | □ | |
1 | 0 | 0 | 1 | ■ | □ | □ | ■ | |
1 | 1 | 1 | 1 | --> | ■ | ■ | ■ | ■ |
1 | 0 | 0 | 1 | ■ | □ | □ | ■ | |
1 | 0 | 0 | 1 | ■ | □ | □ | ■ |
Checkoff:
- What five decimal digits produce the pattern above? What five hexadecimal digits?
- What letter is drawn with 1,1,9,9,6? 0xF8F88?
- What is the hexadecimal representation you would use to spell the letter 'B'? 'N' (you probably won't want to use 5 hex digits for this one)?
Exercise 2: Cisco Binary Game
Click here to find the game. The object is to match the number on the right with the unsigned binary representation on the left. This requires a combination of clicking and typing. And then there's time pressure to make things more fun!
The game gets progressively faster and more difficult are you progress. See if you can score over 20,000 points and get to Level 5!
Checkoff:
- Score over 18,000 points and show your TA (pause the game or screenshot)!
Exercise 3: 1,000 $1 Bills
I hand you a thousand $1 bills and ten envelopes. Your job is to find a way to put various numbers of dollar bills in those ten envelopes so that no matter what amount of money I ask you for (between $1-1000), you can simply hand me some combination of envelopes and always be assured of giving me the correct amount of cash.
Checkoff:
- Explain to your TA how to distribute the dollar bills in the ten envelopes.
Exercise 4: Pearls Before Swine
This is one version of a very cool game that has a neat solution based on number representation.
Play the game here.
First play a few times and see if you can win a few rounds.
After you've tried a few times, give the following Wikipedia article a glance (note that this is the misère version).
With this newfound knowledge in hand, you should be able to beat Juan every time!
But it will likely still take some practice.
Keep going until you can win consistently!
Checkoff:
- Your TA will present to you a hypothetical Pearls Before Swine situation. Work out your next move for the TA.