public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nigel Stephens <nigel@mips.com>
To: Mark Mitchell <mark@codesourcery.com>
Cc: "Fu, Chao-Ying" <fu@mips.com>,
	 gcc-patches@gcc.gnu.org,   "Thekkath,
	Radhika" <radhika@mips.com>
Subject: Re: [ping][patch] Fixed-point patch 2/10
Date: Mon, 06 Aug 2007 19:17:00 -0000	[thread overview]
Message-ID: <46B772CD.3000904@mips.com> (raw)
In-Reply-To: <46B76391.5090708@codesourcery.com>



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

  reply	other threads:[~2007-08-06 19:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-01 23:24 Fu, Chao-Ying
2007-08-06  3:50 ` Mark Mitchell
2007-08-06 17:35   ` Fu, Chao-Ying
2007-08-06 18:08     ` Mark Mitchell
2007-08-06 19:17       ` Nigel Stephens [this message]
2007-08-06 19:56         ` Mark Mitchell
2007-08-06 22:04           ` Fu, Chao-Ying
2007-08-06 23:20             ` Fu, Chao-Ying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46B772CD.3000904@mips.com \
    --to=nigel@mips.com \
    --cc=fu@mips.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mark@codesourcery.com \
    --cc=radhika@mips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).