Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ocaml/num
The legacy Num library for arbitrary-precision integer and rational arithmetic that used to be part of the OCaml core distribution
https://github.com/ocaml/num
Last synced: 2 days ago
JSON representation
The legacy Num library for arbitrary-precision integer and rational arithmetic that used to be part of the OCaml core distribution
- Host: GitHub
- URL: https://github.com/ocaml/num
- Owner: ocaml
- License: other
- Created: 2016-12-08T13:37:06.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-07-02T13:33:20.000Z (3 months ago)
- Last Synced: 2024-09-24T23:07:00.527Z (2 days ago)
- Language: OCaml
- Size: 426 KB
- Stars: 38
- Watchers: 21
- Forks: 28
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog
- License: LICENSE
Awesome Lists containing this project
README
# The Num library for arithmetic on big integers and rationals
## Overview
This library implements arbitrary-precision arithmetic on big integers and on rationals.
This is a legacy library. It used to be part of the core OCaml distribution (in
otherlibs/num
) but is now distributed separately. New applications that need arbitrary-precision arithmetic should use the Zarith library (https://github.com/ocaml/Zarith) instead of the Num library, and older applications that already use Num are encouraged to switch to Zarith. Zarith delivers much better performance than Num and has a nicer API.## Usage
To use the bignum library from your programs, it is recommended to use ocamlfind:
```
ocamlfind ocamlc -package num ...
ocamlfind ocamlopt -package num ...
```
Alternatively, you can do
```
ocamlc nums.cma <.cmo and .ml files>
ocamlopt nums.cmxa <.cmx and .ml files>
```
For toplevel use, just issue the commands
```
#use "topfind";;
#package "num";;
```
or
```
#load "nums.cma";;
```## Documentation
The following modules are documented in their interfaces:
* `Big_int`: operations on arbitrary-precision integers
* `Num`: operations on arbitrary-precision numbers (integers and rationals)
* `Arith_status`: flags that control rational arithmeticMore documentation on the functions provided in this library can be found in _The CAML Numbers Reference Manual_ by Valérie Ménissier-Morain, INRIA technical report 141, july 1992, http://hal.inria.fr/docs/00/07/00/27/PDF/RT-0141.pdf
## Compilation and installation
Prerequisites: OCaml version 4.04 or newer.
```
make all PROFILE=release
make test
make install
make clean
```## History
This library is derived from Valérie Ménissier-Morain's implementation of rational arithmetic for Caml V3.1. Xavier Leroy did the Caml Light port. Victor Manuel Gulias Fernandez did the initial Caml Special Light / OCaml port. Pierre Weis did most of the maintenance and bug fixing.
Initially, the low-level big integer operations were provided by the BigNum package developed by Bernard Serpette, Jean Vuillemin and Jean-Claude Hervé (INRIA and Digital PRL). License issues forced us to replace the BigNum package. The current implementation of low-level big integer operations is due to Xavier Leroy.