Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Integer to floating point conversion errors
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Berke Durak <berke@a...>
Subject: Re: [Caml-list] Integer to floating point conversion errors
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