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
[Caml-list] Big-endian shorts
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-01-14 (15:51)
From: Eric C. Cooper <ecc@c...>
Subject: Re: [Caml-list] Big-endian shorts
On Mon, Jan 14, 2002 at 12:41:09PM +0100, Florian Hars wrote:
> What is the preferred way to read a file with fixed-length records
> consisting of 2700 unsigned, bigendian short ints each in Ocaml?
> Everything is a string?

You can use Bigarray with int16_{signed,unsigned} elements obtained
via map_file.  If you want portability (i.e. on a little-endian
platform), you can optionally byte-swap the int16s arithmetically.
Or you can manipulate chars in a string as you suggest.

Eric C. Cooper          e c c @ c m u . e d u
Bug reports:  FAQ:
To unsubscribe, mail  Archives: