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
[Caml-list] Num library
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sebastien Furic <sebastien.furic@t...>
Subject: Re: [Caml-list] Num library
Claude Marche wrote:
> I have no benchmark to produce, I just want to share my own experience:
> I have an application where integers fit 99% of the time in machine
> ints, but not always, and since I want to be sure that no overflow
> occurs, I use the Num library. Some time ago, I've tried to used mlgmp
> instead. On my own tests, that are not supposed to be exhaustive, mlgmp
> was much faster when computing on really large integers, but when
> integers are small, Num is much faster.
> So I recommend to use mlgmp instead of Num only if you have large
> integers most of the time. I tried also numerix, but it seems not
> maintained anymore. Also I must say I did not use rational numbers.
> As Jean-Christophe said, when using Nums you should take care not to
> use structural equality (Pervasives.(=)) since representation of them
> is not unique. So use Num.eq_num, Num.compare_num instead. Same issue,
> you should not use Pervasives.hash, but something of your own.

 You must use Num.eq_num for another reason: Pervasives.( = ) fails at
runtime on bigints and rationals. I had to rewrite parts of what I
considered "generic" data structures when I have used them to store
objects referencing bignums.


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: