caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David MENTRE <dmentre@linux-france.org>
To: Nicolas George <nicolas.george@ens.fr>
Cc: Caml mailing list <caml-list@inria.fr>
Subject: Re: [Caml-list] How to handle endianness and binary string conversion for 32 bits integers (Int32)?
Date: Thu, 16 Jun 2005 21:32:18 +0200	[thread overview]
Message-ID: <87aclqm725.fsf@linux-france.org> (raw)
In-Reply-To: <20050616190206.GA553@clipper.ens.fr> (Nicolas George's message of "Thu, 16 Jun 2005 21:02:07 +0200")

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


  reply	other threads:[~2005-06-16 19:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-16 18:25 David MENTRE
2005-06-16 19:02 ` [Caml-list] " Nicolas George
2005-06-16 19:32   ` David MENTRE [this message]
2005-06-16 20:14     ` Nicolas George
2005-06-17  7:29     ` Luca Pascali
2005-06-16 22:25 ` Nicolas Cannasse
2005-06-17 18:10   ` David MENTRE

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87aclqm725.fsf@linux-france.org \
    --to=dmentre@linux-france.org \
    --cc=caml-list@inria.fr \
    --cc=nicolas.george@ens.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).