CSCI 2400 Lecture 3: Slides 03

20 views10 pages

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents