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 QAA28686; Fri, 22 Feb 2002 16:54:47 +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 QAA28475 for ; Fri, 22 Feb 2002 16:54:46 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g1MFsi108867; Fri, 22 Feb 2002 16:54:44 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA27687; Fri, 22 Feb 2002 16:54:44 +0100 (MET) Date: Fri, 22 Feb 2002 16:54:44 +0100 From: Xavier Leroy To: Attila Kondacs Cc: caml-list@inria.fr Subject: Re: [Caml-list] reading/converting little endian Message-ID: <20020222165444.D28355@pauillac.inria.fr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from attila@zurich.ai.mit.edu on Tue, Feb 19, 2002 at 10:36:57AM -0500 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > I wonder if there is a way to read or convert little endian numbers > in ocaml. I am trying to write an interface to WAV audio files, and their > headers contain little endian as well as some > big endian words... Your best bet is to read byte per byte and reassemble words yourself: let input_int2_le ic = let b1 = input_byte ic in let b2 = input_byte ic in b1 lor (b2 lsl 8) let input_int2_be ic = let b1 = input_byte ic in let b2 = input_byte ic in (b1 lsl 8) lor b2 and similarly for 4-byte integers. - Xavier Leroy ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners