[NTLK] Re[2]: Newton Streamed Object Decoder

From: Bradford Schmidt (brad_at_bradfordschmidt.com)
Date: Tue Apr 30 2002 - 10:42:51 EDT


Tuesday, April 30, 2002, 4:48:02 AM, Jochen wrote:

> Hi Andrew.

> On Mon, 29 Apr 2002 22:50:00 -0400, Andrew Patrikalakis wrote:

>>endian-ness, someone PLEASE look at byte_order.c and help me with that!).
> Why you do this?

> #ifdef LITTLE_ENDIAN
> char *s;
> s = dest;
> #endif /* LITTLE_ENDIAN */
> memcpy(dest, &l, 4);
> #ifdef LITTLE_ENDIAN
> (*s) = ((((*s) << 24) & 0xFF000000) | (((*s) << 8) &
> 0x00FF0000) | (((*s) >> 8) & 0x0000FF00) | (((*s) >> 24) &
> 0x000000FF));
> #endif /* LITTLE_ENDIAN */

> I would do it like this:

> #ifdef LITTLE_ENDIAN
> char s[4];
> #endif /* LITTLE_ENDIAN */
> memcpy(dest, &l, 4);
> #ifdef LITTLE_ENDIAN
> s[0] = dest[3];
> s[1] = dest[2];
> s[2] = dest[1];
> s[3] = dest[0];
> memcpy(dest, s, 4);
> #endif /* LITTLE_ENDIAN */

> How do you like this?

> Jochen

And a friend of mine calls this a geek list. Sheesh. <g>

Bradford Schmidt
http://www.bradfordschmidt.com
mailto:brad_at_bradfordschmidt.com

-- 
Read the List FAQ/Etiquette: http://www.newtontalk.net/faq.html
Read the Newton FAQ: http://www.guns-media.com/mirrors/newton/faq/
This is the NewtonTalk mailing list - http://www.newtontalk.net



This archive was generated by hypermail 2.1.2 : Sun May 05 2002 - 14:05:33 EDT