Browse thread
How to handle endianness and binary string conversion for 32 bits integers (Int32)?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-06-16 (19:32) |
From: | David MENTRE <dmentre@l...> |
Subject: | Re: [Caml-list] How to handle endianness and binary string conversion for 32 bits integers (Int32)? |
Hello Nicolas, Nicolas George <nicolas.george@ens.fr> writes: >> 1. convert between big and little endian 32 bits integers; > > Don't do that. Except that I'm writing a network interface that should be specified so that externally written programs can read my data. In fact, your post reminded me of a chapter of "The Practice of Programming" by Kernighan and Pike. They advise to read/write integers byte by byte using 8 bit masking and shifting. So I'll follow that approach, which is close to yours and is independent of machine endianness. Thank you for the tip, ;-) Yours, d. -- pub 1024D/A3AD7A2A 2004-10-03 David MENTRE <dmentre@linux-france.org> 5996 CC46 4612 9CA4 3562 D7AC 6C67 9E96 A3AD 7A2A