From: "Maurizio Colucci" <maurizio.colucci@gmail.com>
Cc: tom.primozic@gmail.com, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Re: Reading 16 bit floats from stream?
Date: Tue, 17 Oct 2006 16:02:43 +0200 [thread overview]
Message-ID: <e919163f0610170702r2abe6e49ne97cbed9c1b77faa@mail.gmail.com> (raw)
In-Reply-To: <20061017.082528.59485463.garrigue@math.nagoya-u.ac.jp>
[-- Attachment #1: Type: text/plain, Size: 1059 bytes --]
On 10/17/06, Jacques Garrigue <garrigue@math.nagoya-u.ac.jp> wrote:
>
> 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
Thanks to everybody. I found a library called extlib which provides a module
called IO. I solved the problem with
let l = Int32.float_of_bits (IO.read_real_i32 input)
BTW, I am a bit surprised the standard library does not offer a way to do
that. A simple task can become frustrating.
Bye
Maurizio
[-- Attachment #2: Type: text/html, Size: 1479 bytes --]
next prev parent reply other threads:[~2006-10-17 14:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <e919163f0610160833t6b04489ev46a2c4dd28860729@mail.gmail.com>
2006-10-16 15:44 ` Maurizio Colucci
2006-10-16 16:03 ` Maurizio Colucci
2006-10-16 16:27 ` [Caml-list] " Gerd Stolpmann
2006-10-16 17:06 ` Maurizio Colucci
2006-10-16 17:23 ` Tom
2006-10-16 20:19 ` Martin Jambon
2006-10-16 20:35 ` Tom
2006-10-16 23:25 ` Jacques Garrigue
2006-10-17 14:02 ` Maurizio Colucci [this message]
2006-10-17 14:32 ` Gerd Stolpmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e919163f0610170702r2abe6e49ne97cbed9c1b77faa@mail.gmail.com \
--to=maurizio.colucci@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=tom.primozic@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox