Pre-Lecture Prep and Pre-Quiz

Please read the Bitwise Operators section before class and complete the pre-quiz.

Announcements

Learning Objectives and Outcomes

In this lecture, you will...

By the end of this lecture, you should be able to...

Bitwise Operators

In class so far we have discussed logical operators: logical AND (&&), logical OR (||), and logical NOT (!) and comparison operators (e.g. less than <, equal to (==)). These logical and comparison operators use the entire variable: 7 < 5 compares 7 and 5 and returns false. Bitwise operators are similar to logical operators, but function on individual bits. Let's illustrate this by an example:

$\ \ \ 010$ $\& 011$ ——— $\ \ \ 010$

In this case, an AND is performed for each bit individually. 0 AND 1 is 0, 1 AND 1 is 1, and 0 AND 0 is 0.

Bitwise operators have the following symbols: