Browse thread
[Caml-list] Num library
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| 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 <frisch@clipper.ens.fr> 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é | mailto:Claude.Marche@lri.fr |
| LRI - Bât. 490 | http://www.lri.fr/~marche/ |
| 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 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