Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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