Byte order (retitled)

root rbj at icst-cmr
Wed Apr 30 00:35:05 AEST 1986


> In article <1117 at psivax.UUCP> friesen at psivax.UUCP (Stanley Friesen) writes:
> >In article <2590 at utcsri.UUCP> greg at utcsri.UUCP (Gregory Smith) writes:
> >>...
> >	And I am saying that the following *should* be portable, and
> >that any implementation that it doesn't work on is brain-damaged.
> >
> >	register int i;
> >	unsigned char bytes[ sizeof( long )];		/* lo-byte first */
> >	long input;
> >	register char *cvptr;
> >
> >	for(cvptr = (char *)&input, i = 0; i < sizeof(long); i++)
> >		bytes[i] = cvptr[i];
> >
> Sorry - I thought you were suggesting that big-endian pointer conversions
> should set the lower bits (when pointing to a smaller object) and clear
> them (when pointing to a larger one). What you are actually saying is
> that any implementation which is not strictly little-endian is 'brain-
> damaged' (Including (a) PDP11 _longs_, (b) 68000). I will agree that (a)
> is brain-damaged, but I think the adjective is a little strong for (b).
> I am a little-end fan myself, but I can face reality, and the reality is
> there will be big-endian machines around that are still worth using, and
> that the 'problem' can be dealt with so easily that one needn't damn
> the 68K to eternal flames on this one point.
> 
> "For every action there is an equal and opposite malfunction"
> ----------------------------------------------------------------------
> Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

To all you Big Endian fans out there: What's your problem? You guys
are the ones saying that the first byte is the most significant, so
why are y'all bitchin that you don't get the low byte like on *sane*
machines? Axually, I like the 680[012]0 also. Byte order doesn't really
bother me either way except as an academic issue.

I don't see the need or the possibility for your example to be both
portable and work the way you described. The two are at odds.
Remember, C does what you tell it to do, not what you think it should do.

	(Root Boy) Jim Cottrell		<rbj at cmr>
	"One man gathers what another man spills"



More information about the Comp.lang.c mailing list