Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: [Caml-list] Runtime overflow and what to do
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: John Carr <jfc@M...>
Subject: Re: [Caml-list] Runtime overflow and what to do

> 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 Archives:
Bug reports: FAQ:
Beginner's list: