From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 28CFFBC68 for ; Tue, 17 Oct 2006 01:31:05 +0200 (CEST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id k9GNUv4N028449 for ; Tue, 17 Oct 2006 01:30:59 +0200 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.7/8.13.7) with ESMTP id k9GNPu35028949; Tue, 17 Oct 2006 08:25:56 +0900 (JST) Date: Tue, 17 Oct 2006 08:25:28 +0900 (JST) Message-Id: <20061017.082528.59485463.garrigue@math.nagoya-u.ac.jp> To: tom.primozic@gmail.com Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Re: Reading 16 bit floats from stream? From: Jacques Garrigue In-Reply-To: References: X-Mailer: Mew version 5.1 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 45341632.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; val:01 pervasives:01 binary:01 ocaml:01 int's:01 integers:01 val:01 pervasives:01 ocaml:01 marshal:01 caml-list:01 integer:01 integer:01 int:01 int:01 From: Tom > 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