/* Determine whether arguments can be multiplied without overflow */
int tmult_ok(int x, int y) {
int p = x * y;
return !x || p/x == y;
}
- For x and y such that
$TMin \le x,y \le TMax$ : $x y = U2T(( x y ) mod 2^w) = p + t * 2^w$, if positive overflow, $ t = -1$, else if negative overflow,$t = 1$ . -
$r$ is remainder. - if
$q$ equal$y$ , then $xy - t2^w = x y + r$, then $r + tw^ = 0$, And$|r|< |x| < 2^w$ , so$t=0$ , then$r=0$ .