From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3837 invoked by alias); 24 Mar 2006 03:00:49 -0000 Received: (qmail 3795 invoked by uid 22791); 24 Mar 2006 03:00:49 -0000 X-Spam-Check-By: sourceware.org Received: from Unknown (HELO easeserver.easesoftware.net) (64.192.143.210) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 24 Mar 2006 03:00:48 +0000 Received: from [64.192.143.213] (small-fry.easesoftware.net [64.192.143.213]) by easeserver.easesoftware.net (Postfix) with ESMTP id AD5A91AC0A2 for ; Thu, 23 Mar 2006 21:00:47 -0600 (CST) Mime-Version: 1.0 (Apple Message framework v746.2) Content-Transfer-Encoding: 7bit Message-Id: <9DD53BC1-A06B-499B-8BA0-E23D82476F1C@easesoftware.net> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: gcc-help@gcc.gnu.org From: Perry Smith Subject: integral type conversions Date: Fri, 24 Mar 2006 03:00:00 -0000 X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2006-03/txt/msg00170.txt.bz2 I can't understand the C++ spec. It seems more vague than the old K&R. If the source is a signed integral type and the destination is an unsigned integral type that is larger, are the additional bits done via sign extension or zero extension? e.g. int i; unsigned long l = i; Is i sign extended from int to long and then converted to unsigned long or is it converted to unsigned int and then zero extended to unsigned long? (assume that long is bigger in this case). I'm actually going from a long to an unsigned long long but I assume the same algorithm is used. I guess, to be safe, I could do: unsigned long l = static_cast(i); Thank you, Perry