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: 2002-10-11 (15:41)
From: Claude Marche <Claude.Marche@l...>
Subject: Re: [Caml-list] Num library

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.

Hope this helps.

- Claude

>>>>> "Alain" == Alain Frisch <> writes:

    Alain> Hello Caml List,
    Alain> I'm considering using the Num library (from the standard distribution) for
    Alain> implementing numbers in an interpreter. Questions:

    Alain> - Is there any benchmark available ?  What is the overhead when dealing
    Alain>   with "small" integers ?

    Alain> - How does the library compare with other large/rational numbers
    Alain>   implementations ?

    Alain> - The manual mentions two special elements 1/0 and 0/0; it seems
    Alain>   that -1/0 is also available. Is it a bug in the manual or the
    Alain>   implementation ?

    Alain> -- Alain

| Claude Marché           | |
| LRI - Bât. 490          |  |
| Université de Paris-Sud | phoneto: +33 1 69 15 64 85  |
| F-91405 ORSAY Cedex     | faxto: +33 1 69 15 65 86    |
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: