CSCI 2400 Lecture 3: Slides 03
Document Summary
Implements modular arithmetic s = uadd (u, v) = u + v mod 2. Signed vs. unsigned addition in c int s, t, u, v; s = (int) ((unsigned) u + (unsigned) v); Positive overflow: when you add two positive number and you get negative result. Negative overflow: when you add two negative numbers and you get positive result. Goal: computing product of -bit numbers x, y. But, exact results can be bigger than w bits. Two"s complement min (negative): up to 2 bits. Two"s complement max (positive): up to 2 bits, but only for (tmin ) Would need to keep expanding word size with each product computed. Is done in software, if needed e. g. , by arbitrary precision arithmetic packages. Umult (u, v) = u v mod 2. Some of which are different for signed vs. unsigned multiplication. U << k gives u * 2. (u << 5) - (u <<3) == u*24.