Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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 <> 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