Version française
Home     About     Download     Resources     Contact us    
Browse thread
Reading 16 bit floats from stream?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] Re: Reading 16 bit floats from stream?
From: Tom <tom.primozic@gmail.com>

> val Pervasives.input_binary_int : in_channel -> int

This will indeed read a 32-bit integer, but on a 32-bit architecture
ocaml int's are 31-bit, so you loose the highest bit.
Note that on a 64-bit architecture this is sufficient for 32-bit
integers!

> val Pervasives.read_int : unit -> int

This one reads a string...

> val Marshal.from_channel : in_channel -> 'a

And this one reads a marshalled value, which must include a special
header indicating its ocaml representation.

So if you really need to read a full 32-bit integer, none of these
will work, and you must do the job by hand.

Jacques Garrigue