www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/16/12:10:41

From: kagel AT quasar DOT bloomberg DOT com
Date: Thu, 16 May 1996 11:59:26 -0400
Message-Id: <9605161559.AA04695@quasar.bloomberg.com >
To: hinks AT netspace DOT net DOT au
Cc: eliz AT is DOT elta DOT co DOT il, lav AT video DOT yars DOT free DOT net, djgpp AT delorie DOT com,
j DOT aldrich6 AT genie DOT com
In-Reply-To: <199605160145.LAA17047@tornado.netspace.net.au> (message from Adam Hinkley on Thu, 16 May 96 11:50:51 +1000)
Subject: Re: 64-bit integers
Reply-To: kagel AT dg1 DOT bloomberg DOT com

   Errors-To: postmaster AT ns1
   Date: Thu, 16 May 96 11:50:51 +1000
   From: Adam Hinkley <hinks AT netspace DOT net DOT au>
   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
   Content-Type: text/plain; charset="US-ASCII"
   Content-Length: 1318

   >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;

Take your pick.  Long long is not a native Intel data type so the endian-ness
of the two longs is irrelevant!  It does not matter.

-- 
Art S. Kagel, kagel AT quasar DOT bloomberg DOT com

A proverb is no proverb to you 'till life has illustrated it.  -- John Keats

- Raw text -


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