This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: signed/unsigned right shift
- From: Andreas Schwab <schwab at suse dot de>
- To: Christian Groessler <cpg at aladdin dot de>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 12 Mar 2004 23:24:28 +0100
- Subject: Re: signed/unsigned right shift
- References: <87wu5pwyg7.fsf@aladdin.de>
Christian Groessler <cpg@aladdin.de> writes:
> I have the following program which takes 2 unsigned short values,
> multiplies them and shifts the result right.
>
> This right shift gives a value with 1s bits at the high end.
This is correct. The promotion rules let unsigned short promote to int,
since the latter can represent all values of the former.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."