Recitation 03: Integers
- Integers and Twos Compliment Representation.
- If we have a binary number with n bits represented as $b_{n-1}b_{n-2}
\ldots b_2b_1b_0$, we can calculate its decimal value as:
$$-b_{n-1} \times 2^{n-1} + \sum_{i=0}^{n-2} b_i \times 2^i$$
- To reinforce the modular arithmetic properties of ints, we can
visualize the points as lying along the edge of a circle. Example. Credit to
Josh Zimmerman for this example.
- A few slides borrowed from 15-213 with
some helpful graphics to help visualize int properties.
- Discussed bitwise not (~) and the property that $-x = \sim x +
1$.
If you have any comments or see any errors, please
let me know.