1994-02-11 - Magic money not working bigendian

Header Data

From: hughes@ah.com (Eric Hughes)
To: cypherpunks@toad.com
Message Hash: 36769259acd920b8a03d70e3f6cfbe46454bac45f95b241e4cf52ab7a4e66a02
Message ID: <9402110150.AA09132@ah.com>
Reply To: <199402110108.RAA06533@math.berkeley.edu>
UTC Datetime: 1994-02-11 02:00:25 UTC
Raw Date: Thu, 10 Feb 94 18:00:25 PST

Raw message

From: hughes@ah.com (Eric Hughes)
Date: Thu, 10 Feb 94 18:00:25 PST
To: cypherpunks@toad.com
Subject: Magic money not working bigendian
In-Reply-To: <199402110108.RAA06533@math.berkeley.edu>
Message-ID: <9402110150.AA09132@ah.com>
MIME-Version: 1.0
Content-Type: text/plain


Try this:

--------------------------------------------
#include <stdio.h>

main()
{
	long t = 1 ;
	char *cp = (char *) & t  ;

	printf( "%s-endian\n", ( *cp != 0 ) ? "little" : "big" ) ;
}
--------------------------------------------

On a little-endian machine, the least significant byte is stored
first; on big-endian, the most significant.  The address of a long
points to the first byte, i.e. the byte with the lowest address.  The
above program tests to see if the first byte is non-zero, which is
true iff the length of a char is less than the length of a long
(usually true) and if the least significant byte is first, i.e.
little-endian.

Further responses should go only to my mailbox.

Eric





Thread