From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5002 invoked by alias); 12 Mar 2004 22:24:31 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 4984 invoked from network); 12 Mar 2004 22:24:30 -0000 Received: from unknown (HELO Cantor.suse.de) (195.135.220.2) by sources.redhat.com with SMTP; 12 Mar 2004 22:24:30 -0000 Received: from hermes.suse.de (Hermes.suse.de [195.135.221.8]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by Cantor.suse.de (Postfix) with ESMTP id 8078E2E384B; Fri, 12 Mar 2004 23:24:29 +0100 (CET) To: Christian Groessler Cc: gcc@gcc.gnu.org Subject: Re: signed/unsigned right shift References: <87wu5pwyg7.fsf@aladdin.de> From: Andreas Schwab X-Yow: ..Am I in a SOAP OPERA?? Date: Fri, 12 Mar 2004 22:24:00 -0000 In-Reply-To: <87wu5pwyg7.fsf@aladdin.de> (Christian Groessler's message of "12 Mar 2004 22:24:40 +0100") Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-SW-Source: 2004-03/txt/msg00593.txt.bz2 Christian Groessler 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."