Version française
Home     About     Download     Resources     Contact us    
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.

 Cheers,

 Sebastien.
-------------------
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