English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
reading/writing binary data
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-11-21 (13:56)
From: Dmitry Bely <dmitry.bely@g...>
Subject: Re: [Caml-list] reading/writing binary data
On 11/21/06, Dário Abdulrehman <drehman31@gmail.com> wrote:

> Is there some library for writing binary int (not int32) that writes the
> data in little endian (I think map_file reads it back in little endian on my
> processor) ?

Yes, sure - the library is below :)

let output_binary_int_little_endian ch n =
  output_byte ch (n land 0xff);
  output_byte ch ((n lsr 8) land 0xff);
  output_byte ch ((n lsr 16) land 0xff);
  output_byte ch ((n lsr 24) land 0xff)

- Dmitry Bely