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 LAA10589; Sun, 11 Nov 2001 11:59:36 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA10894 for caml-list@pauillac.inria.fr; Sun, 11 Nov 2001 11:59:35 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA29214 for ; Sat, 10 Nov 2001 00:40:02 +0100 (MET) Received: from mail.virginia.edu (mail.Virginia.EDU [128.143.2.9]) by nez-perce.inria.fr (8.11.1/8.10.0) with SMTP id fA9Ne1518159 for ; Sat, 10 Nov 2001 00:40:01 +0100 (MET) Received: from config.mail.virginia.edu by mail.virginia.edu id aa29380; 9 Nov 2001 18:39 EST Received: from localhost (fjr6b@localhost) by config.mail.Virginia.EDU (8.9.3/8.9.3) with ESMTP id SAA16456 for ; Fri, 9 Nov 2001 18:39:58 -0500 (EST) Date: Fri, 9 Nov 2001 18:39:58 -0500 (EST) From: Post Office!~/sentmail X-X-Sender: To: caml-list@inria.fr MMDF-Warning: Parse error in original version of preceding line at mail.virginia.edu Subject: [Caml-list] Integer to floating point conversion errors Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I am getting negative results when I convert large integers to floating point. This happens on both i386 and my G4 laptop with OCaml 3.02. The code in question is this: class prng = fun m i mo -> (fun (sd:int) -> object (self) val mutable seed = sd val mult = m val incr = i val modu = mo method getseed = seed method raw = (seed <- (seed*mult+incr)mod modu); float seed /. float modu method gen low high = let range = high -. low in (self#raw *. range) +. low end);; let myprng = new prng 274177 13 1073741824;; let seeded = myprng 44;; Then use seeded#raw a few times: the results are quite often negative, which they should not be so far as I can see. Can anyone advise me how to fix this? Fred Ross High Energy Physics Lab University of Virginia ------------------- 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