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 RAA14956; Sun, 11 Nov 2001 17:19:32 +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 RAA15100 for caml-list@pauillac.inria.fr; Sun, 11 Nov 2001 17:19:31 +0100 (MET) 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 QAA14821 for ; Sun, 11 Nov 2001 16:35:48 +0100 (MET) Received: from mail.virginia.edu (mail.Virginia.EDU [128.143.2.9]) by concorde.inria.fr (8.11.1/8.10.0) with SMTP id fABFZln01714 for ; Sun, 11 Nov 2001 16:35:47 +0100 (MET) Received: from config.mail.virginia.edu by mail.virginia.edu id aa12612; 11 Nov 2001 10:35 EST Received: from localhost (fjr6b@localhost) by config.mail.Virginia.EDU (8.9.3/8.9.3) with ESMTP id KAA26823 for ; Sun, 11 Nov 2001 10:35:39 -0500 (EST) Date: Sun, 11 Nov 2001 10:35:39 -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: Re: [Caml-list] Integer to floating point conversion errors In-Reply-To: <20011111143319.A14950@gogol.zorgol> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, 11 Nov 2001, Berke Durak wrote: Pardon me, I wasn't clear. Since incr and mult are assumed to be positive, seed should always be positive. Therefore a mod of C by a positive number should always be positive. The problems arise like the following: # seeded#raw;; - : float = -0.011235290207 # seeded#getseed;; - : int = 12063801 # float ( seeded#getseed );; - : float = 12063801 # float ( seeded#getseed ) /. float( 1073741824 );; - : float = -0.011235290207 # float (1073741824);; - : float = -1073741824 > On Fri, Nov 09, 2001 at 06:39:58PM -0500, Post Office!~/sentmail wrote: > > 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: > > > > method raw = (seed <- (seed*mult+incr)mod modu); > > float seed /. float modu > > The operator ``mod'' does not necessarily return positive values (depending > on your platform) : > > Objective Caml version 3.03 ALPHA > # (-1) mod 5;; > - : int = -1 > -- > Berke > ------------------- 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