Pre-Lecture Prep and Pre-Quiz
Please read the "signed numbers and complements" section and complete the pre-quiz on moodle.
Announcements
- Homework 3 is due Tuesday at 11:40am EDT.
- Please fill out the group work assessment form for us to help re-arrange breakout rooms.
- The midterm will be October 15th. More details TBD. You can check the schedule to see what we're covering the course next (also linked on Notion and Moodle).
- Office hours and wizard sessions:
- Delano: currently Mondays at 3pm-5pm EDT (same zoom link as lecture), or by appointment (please vote on whether we should move these to Weds)
- Cheever: check his schedule
- Ruether: by appointment Wednesdays 10am-12pm, Thursdays 3pm-5pm EDT (link)
- Wizard sessions: Sunday 1-3pm EDT, Monday 7-9pm EDT (zoom link on moodle)
Learning Objectives and Outcomes
In this lecture, you will...
- Read a short lecture on signed numbers and complements and complete a pre-quiz
- Listen to a short lecture about performing arithmetic in binary, including shifting and padding
By the end of this lecture, you should be able to...
- Convert a signed decimal number to its complement representation, and vice versa
- Perform addition and subtraction using signed binary numbers, using padding as necessary
- Use the shift operators
<<
and >>
to multiply and divide variables
Signed Numbers
When we introduced the variable types byte
, unsigned int
and int
, we discussed how only the int
type is signed, and that it had a range of -32,768 to 32,767 instead of the unsigned version, which had a range of 0 to 65,535. Both int
and unsigned int
are 16-bit binary numbers; the difference is how those $2^{16}-1$ values are allocated.
Let's consider a 3-bit unsigned number first. We can think of binary numbers as a circle: