From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA13001; Fri, 9 Nov 2001 14:32:22 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA13150; Fri, 9 Nov 2001 14:32:21 +0100 (MET) Received: from heplix4.ikp.physik.tu-darmstadt.de (heplix4.ikp.physik.tu-darmstadt.de [130.83.210.158]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id fA9DWLn09170; Fri, 9 Nov 2001 14:32:21 +0100 (MET) Received: (from ohl@localhost) by heplix4.ikp.physik.tu-darmstadt.de (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id fA9DWIE21955; Fri, 9 Nov 2001 14:32:18 +0100 From: Thorsten Ohl MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15339.56034.169961.457637@heplix4.ikp.physik.tu-darmstadt.de> Date: Fri, 9 Nov 2001 14:32:18 +0100 To: Caml List Cc: Xavier Leroy In-Reply-To: <20011109131841.A5769@pauillac.inria.fr> References: <20011109112909.A9417@team.ph.inter.net> <15339.47220.792529.380015@heplix4.ikp.physik.tu-darmstadt.de> <20011109131841.A5769@pauillac.inria.fr> X-Mailer: VM 6.84 under Emacs 20.7.1 Reply-To: ohl@hep.tu-darmstadt.de Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Starting with OCaml 3.01, the Int64 module provides two functions > "bits_of_float" and "float_of_bits" which convert between floats and > an int64 matching the underlying 64-bit representation of the float. Thanks. I forgot to look among the Int* modules when I was hunting for floating point conversions :-(. > > external float_of_bytes : string -> float = "float_of_bytes" > > b) on little endian machines one has to swap bytes. > > b) is not (big endian representation is enforced). Now I'm confused. On my Linux box, I have to swap bytes in order to read binary floating point numbers from a stream (where I can not mmap Bigarrays). let unsafe_rev8 s = let swap i1 i2 = let tmp = String.unsafe_get s i1 in String.unsafe_set s i1 (String.unsafe_get s i2); String.unsafe_set s i2 tmp in swap 0 7; swap 1 6; swap 2 5; swap 3 4 let little_endian = true let input_binary_float ic = let buf = String.create 8 in really_input ic buf 0 8; if little_endian then unsafe_rev8 buf; float_of_bytes buf But that's academical, because I will switch to Int64 now. Thanks again. -- Thorsten Ohl, Physics Department, TU Darmstadt -- ohl@hep.tu-darmstadt.de http://heplix.ikp.physik.tu-darmstadt.de/~ohl/ [<=== PGP public key here] ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr