Skip to content

Commit

Permalink
Merge branch 'master' into features/tommath-support
Browse files Browse the repository at this point in the history
Add unsigned int support for `fits_` and `to_` functions
  • Loading branch information
antoinemine committed Aug 20, 2024
2 parents f7bb20b + a079848 commit 40059f3
Show file tree
Hide file tree
Showing 32 changed files with 1,921 additions and 1,988 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Default behaviour, for if core.autocrlf isn't set
* text=auto

configure text eol=lf
49 changes: 49 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: build

on:
pull_request:
push:
branches:
- master
schedule:
# Prime the caches every Monday
- cron: 0 1 * * MON

jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
ocaml-compiler:
- "4.14"
- "5.2"

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set-up OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}

- run: opam install . --with-test --deps-only

- name: configure tree
run: opam exec -- sh ./configure

- name: Build
run: opam exec -- make

- name: Run the testsuite
run: opam exec -- make -C tests test

- run: opam install . --with-test

- run: opam exec -- git diff --exit-code
25 changes: 25 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
Release 1.14 (2024-07-10)
- #148, #149: Fail unmarshaling when it would produce non-canonical big ints
- #145, #150: Use standard hash function for `Z.hash` and add `Z.seeded_hash`
- #140, #147: Add fast path for `Z.divisible` on small arguments

Release 1.13 (2023-07-19)
- #113: add conversions to/from small unsigned integers `(to|fits)_(int32|int64|nativeint)_unsigned` [Antoine Miné]
- #128: add functions to pseudo-randomly generate integers [Xavier Leroy]
- #105: add `Big_int.big_int_of_float` [Yishuai Li]
- #90: add fast path to `Z.extract` when extraction leads to a small integer [Frédéric Recoules]
- #137: more precise bounds for of_float conversion to small ints [Antoine Miné]
- #118: fix Z_mlgmpidl interface for mlgmpidl >= 1.2 [Simmo Saan]
- #109: fix typo in `ml_z_mul` function [Bernhard Schommer]
- #108: fix dependency on C evaluation order in `ml_z_remove` [Xavier Clerc]
- #117 #120 #129 #132 #135 #139 #141: configure & build simplifications and fixes [various authors]
- #134: CI testing: add Windows, test both 4.14 and 5.0 [Hugo Heuzard]

Release 1.12 (2021-03-03)
- PR #79: fast path in OCaml (instead of assembly language) [Xavier Leroy]
- PR #94: remove source preprocessing and simplify configuration [Xavier Leroy]
- PR #93: fix parallel build [Guillaume Melquiond]
- PR #92: fix benchmark for subtraction [Guillaume Melquiond]
- Require OCaml 4.04 or later [Xavier Leroy]
- Add CI testing on macOS [Xavier Leroy]

Release 1.11 (2020-11-09)
- Fixes #72, #75, #78: multiple fixes for of_string, support for underscores [hhugo]
- Fix #74: fix Q.to_float for denormal numbers [pascal-cuoq]
Expand Down
6 changes: 4 additions & 2 deletions META
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
description = "Arbitrary precision integers"
requires = ""
version = "1.11"
version = "1.14"
archive(byte) = "zarith.cma"
archive(native) = "zarith.cmxa"
plugin(byte) = "zarith.cma"
plugin(native) = "zarith.cmxs"

package "top" (
version = "1.11"
version = "1.13"
description = "ZArith toplevel support"
requires = "zarith"
archive(byte) = "zarith_top.cma"
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ arbitrary-precision integers.

The module is simply named `Z`. Its interface is similar to that of
the `Int32`, `Int64` and `Nativeint` modules from the OCaml standard
library, with some additional functions. See the file `z.mlip` for
library, with some additional functions. See the file `z.mli` for
documentation.

The implementation uses GMP (the GNU Multiple Precision arithmetic
Expand All @@ -27,6 +27,9 @@ Additional features include:
* a module `Q` for rationals, built on top of `Z` (see `q.mli`)
* a compatibility layer `Big_int_Z` that implements the same API as Big_int from the legacy `Num` library, but uses `Z` internally

Support for [js_of_ocaml](https://github.com/ocsigen/js_of_ocaml/) is
provided by [Zarith_stubs_js](https://github.com/janestreet/zarith_stubs_js).

## REQUIREMENTS

* OCaml, version 4.04.0 or later.
Expand Down Expand Up @@ -126,6 +129,7 @@ Source files | Description
z_mlgmpidl.ml[i] | conversion between Zarith and MLGMPIDL
tests/ | simple regression tests and benchmarks


## BACK-END COMPATIBILITY

Zarith supports several back-ends to implement multi-word integers: GMP, MPIR, and LibTomMath.
Expand All @@ -134,10 +138,10 @@ The `configure` script will try them in the following order: GMP, MPIR, LibTomMa
The choice of back-end can be overridden with the `-gmp`, `-mpir`, and `-tommath` configure options.

GMP and MPIR support all functions and should give identical results.
The hashing function is notably identical and the marshalling format is compatible for GMP and MPIR, and for 32-bit and 64-bit.
The hashing function is identical and the marshalling format is compatible for GMP and MPIR, and for 32-bit and 64-bit.

LibTomMath support is partial and experimental.
Not all functions are implemented.
Not all functions are implemented.
Unsupported functions raise a `Failure` exception.
The hashing function is different from the GMP/MPIR one, and the hashed value actually depends on the digit bit-size used by LibTomMath (which can be queried with `digit_bits ()`).
Additionally, the marshaling format is incompatible with the GMP/MPIR one, although it is independent from the digit bit-size.
2 changes: 2 additions & 0 deletions big_int_Z.ml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ let int64_of_big_int x =

let float_of_big_int = Z.to_float

let big_int_of_float = Z.of_float

let and_big_int = Z.logand

let or_big_int = Z.logor
Expand Down
1 change: 1 addition & 0 deletions big_int_Z.mli
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ val int32_of_big_int : Z.t -> int32
val nativeint_of_big_int : Z.t -> nativeint
val int64_of_big_int : Z.t -> int64
val float_of_big_int : Z.t -> float
val big_int_of_float : float -> Z.t
val and_big_int : Z.t -> Z.t -> Z.t
val or_big_int : Z.t -> Z.t -> Z.t
val xor_big_int : Z.t -> Z.t -> Z.t
Expand Down
Loading

0 comments on commit 40059f3

Please sign in to comment.