Path: utzoo!utgpu!water!watmath!clyde!att!rutgers!mit-eddie!ll-xn!ames!elroy!gryphon!vector!rpp386!jfh
From: jfh@rpp386.UUCP (The Beach Bum)
Newsgroups: comp.lang.c
Subject: Re: Multiplying two shorts...
Summary: 16 x 16 always fits in 32 bits
Message-ID: <5534@rpp386.UUCP>
Date: 17 Aug 88 13:38:05 GMT
References: <948@srs.UUCP> <8101@alice.UUCP> <576@proxftl.UUCP>
Reply-To: jfh@rpp386.UUCP (The Beach Bum)
Organization: HASA, "S" Division
Lines: 17

In article <576@proxftl.UUCP> bill@proxftl.UUCP (T. William Wells) writes:
>What this means is that if the product of the values of the two
>shorts will fit in an int, the code will work as expected.  If
>not, then the result IS undefined.

since this discussion orginally involved 16x16=32 multiply instructions,
i thought it might be nice to point out that any two 16 bit numbers can
be multiplied, and the result will always fit in 32 bits, without 
overflow.

unsigned:	FFFF x FFFF = FFFE0001
signed:		7FFF x 7FFF = 3FFF0001
-- 
John F. Haugh II                 +--------- Cute Chocolate Quote ---------
HASA, "S" Division               | "USENET should not be confused with
UUCP:   killer!rpp386!jfh        |  something that matters, like CHOCOLATE"
DOMAIN: jfh@rpp386.uucp          |         -- apologizes to Dennis O'Connor