From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8787 invoked by alias); 6 Aug 2007 19:17:38 -0000 Received: (qmail 8683 invoked by uid 22791); 6 Aug 2007 19:17:37 -0000 X-Spam-Check-By: sourceware.org Received: from dmz.mips-uk.com (HELO dmz.mips-uk.com) (194.74.144.194) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 06 Aug 2007 19:17:35 +0000 Received: from internal-mx1 ([192.168.192.240] helo=ukservices1.mips.com) by dmz.mips-uk.com with esmtp (Exim 3.35 #1 (Debian)) id 1II822-0005v8-00; Mon, 06 Aug 2007 20:14:22 +0100 Received: from ukcvpn45.mips-uk.com ([192.168.193.45]) by ukservices1.mips.com with esmtp (Exim 3.36 #1 (Debian)) id 1II81u-00049Y-00; Mon, 06 Aug 2007 20:14:14 +0100 Message-ID: <46B772CD.3000904@mips.com> Date: Mon, 06 Aug 2007 19:17:00 -0000 From: Nigel Stephens User-Agent: IceDove 1.5.0.12 (X11/20070607) MIME-Version: 1.0 To: Mark Mitchell CC: "Fu, Chao-Ying" , gcc-patches@gcc.gnu.org, "Thekkath, Radhika" Subject: Re: [ping][patch] Fixed-point patch 2/10 References: <3CB54817FDF733459B230DD27C690CEC03EE8EFD@Exchange.mips.com> <46B76391.5090708@codesourcery.com> In-Reply-To: <46B76391.5090708@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-MIPS-Technologies-UK-MailScanner: Found to be clean X-MIPS-Technologies-UK-MailScanner-From: nigel@mips.com X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-08/txt/msg00382.txt.bz2 Mark Mitchell wrote: > Fu, Chao-Ying wrote: > > >> Ex 2: (A and B are negative. ) >> A.high = 0xffffffffffffffff and A.low = 0x8000000000000000 >> B.high = 0xffffffffffffffff and B.low = 0x0000000000000001 >> => A > B, >> because A.high == B.high and >> (unsigned HOST_WIDE_INT) a.low > (unsigned HOST_WIDE_INT) b.low >> > > Yes, I see; two's complement is set up so that after masking the sign > bit, you can do an unsigned compare. Thank you for explaining. > Since double_int is already declared with low unsigned, like this: typedef struct { unsigned HOST_WIDE_INT low; HOST_WIDE_INT high; } double_int; Would it be more obvious to simply remove the casts altogether, e.g. double_int_scmp (double_int a, double_int b) { if (a.high < b.high) return -1; if (a.high > b.high) return 1; if (a.low < b.low) return -1; if (a.low > b.low) return 1; return 0; } Nigel