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 SAA02635; Sat, 12 Oct 2002 18:13:38 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 SAA02515 for ; Sat, 12 Oct 2002 18:13:36 +0200 (MET DST) Received: from pacific-carrier-annex.mit.edu (PACIFIC-CARRIER-ANNEX.MIT.EDU [18.7.21.83]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g9CGDZD21088 for ; Sat, 12 Oct 2002 18:13:36 +0200 (MET DST) Received: from grand-central-station.mit.edu (GRAND-CENTRAL-STATION.MIT.EDU [18.7.21.82]) by pacific-carrier-annex.mit.edu (8.9.2/8.9.2) with ESMTP id MAA22211; Sat, 12 Oct 2002 12:13:34 -0400 (EDT) Received: from melbourne-city-street.mit.edu (MELBOURNE-CITY-STREET.MIT.EDU [18.7.21.86]) by grand-central-station.mit.edu (8.9.2/8.9.2) with ESMTP id MAA07015; Sat, 12 Oct 2002 12:13:33 -0400 (EDT) Received: from psi-phi.mit.edu (PSI-PHI.MIT.EDU [18.187.1.35]) by melbourne-city-street.mit.edu (8.9.2/8.9.2) with ESMTP id MAA16516; Sat, 12 Oct 2002 12:13:32 -0400 (EDT) Received: (from jfc@localhost) by psi-phi.mit.edu (8.9.3) id MAA27433; Sat, 12 Oct 2002 12:13:32 -0400 Message-Id: <200210121613.MAA27433@psi-phi.mit.edu> To: Alessandro Baretta cc: Ocaml Subject: Re: [Caml-list] Runtime overflow and what to do In-Reply-To: Your message of "Fri, 11 Oct 2002 12:16:13 +0200." <3DA6A4ED.5050700@baretta.com> Date: Sat, 12 Oct 2002 12:13:32 -0400 From: John Carr Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > If your problem is only the factorial function, then you can > calculate statically (i.e. at source-code writing time) the > value of the maximum integer whose factorial will fit in > O'Caml's representation of integers, and test against that, > once and for all, before entering the recursive calculation. OCaml supports 32 and 64 bit integers. Is it possible to detect at compile time the size of the maximum integer? In the case of factorial, you could almost as easily optimize the function to a table lookup. ------------------- 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