Unsigned Integer Encoding

Wojciech Puchar wojtek at wojtek.tensor.gdynia.pl
Wed Aug 15 13:34:54 UTC 2012


> /* This prints 04030201 */
> printf ("b= %0X \n", *b);
>
all is OK, you did this probably on x86 CPU which is little endian. on 
powerpc it would be 01020304 as it is big endian.

to write endian independent code:

man htonl

all these are macros actually.

"network order" is big endian. so eg htonl would reverse order on x86, and 
ddo nothing on powerpc.




More information about the freebsd-hackers mailing list