www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/15/21:48:24

Message-Id: <199605160145.LAA17047@tornado.netspace.net.au>
Subject: Re: 64-bit integers
Date: Thu, 16 May 96 11:50:51 +1000
From: Adam Hinkley <hinks AT netspace DOT net DOT au>
To: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
cc: <lav AT video DOT yars DOT free DOT net>, <djgpp AT delorie DOT com>, <j DOT aldrich6 AT genie DOT com>
Mime-Version: 1.0

>The old v1.x library sources archive (djlsr112.zip) included the sources 
>for these functions; if you can get that, you won't need to download the 
>multi-megabyte gcc distribution.

This source is for a big endian right?

I don't have the definition for DItype, but the PowerPC is a little 
endian, which means I have defined it as:

    typedef struct {
        long high;               // little endian
        unsigned long low;
    } DItype;

Would I be correct in saying the big endian version would make "low" 
signed instead of "high"?

So, am I correct in assuming that if djlsr112 typecasts low to unsigned, 
I should do the opposite?

For example, if this is for big endians....

    if (au.s.high < bu.s.high)
        return -1;
    else if (au.s.high > bu.s.high)
        return 1;
    if ((unsigned long) au.s.low < (unsigned long)bu.s.low)
        return -1;
    else if ((unsigned long) au.s.low > (unsigned long)bu.s.low)
        return 1;

...then to make it work on little endians, I should change it to...

    if ((unsigned long)au.s.high < (unsigned long)bu.s.high)
        return -1;
    else if ((unsigned long)au.s.high > (unsigned long)bu.s.high)
        return 1;
    if (au.s.low < bu.s.low)
        return -1;
    else if (au.s.low > bu.s.low)
        return 1;

Correct?

Thanks

Adam

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019