1 Copyright 2011-2013 Free Software Foundation, Inc.
3 This file is part of the GNU MP Library.
5 The GNU MP Library is free software; you can redistribute it and/or modify
6 it under the terms of either:
8 * the GNU Lesser General Public License as published by the Free
9 Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
14 * the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any
18 or both in parallel, as here.
20 The GNU MP Library is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 You should have received copies of the GNU General Public License and the
26 GNU Lesser General Public License along with the GNU MP Library. If not,
27 see https://www.gnu.org/licenses/.
30 This is "mini-gmp", a small implementation of a subset of GMP's mpn
33 It is intended for applications which need arithmetic on numbers
34 larger than a machine word, but which don't need to handle very large
35 numbers very efficiently. Those applications can include a copy of
36 mini-gmp to get a GMP-compatible interface with small footprint. One
37 can also arrange for optional linking with the real GMP library, using
38 mini-gmp as a fallback when for some reason GMP is not available, or
39 not desired as a dependency.
41 The supported GMP subset is declared in mini-gmp.h. The implemented
42 functions are fully compatible with the corresponding GMP functions,
43 as specified in the GMP manual, with a few exceptions:
45 mpz_set_str, mpz_init_set_str, mpz_get_str, mpz_out_str and
46 mpz_sizeinbase support only |base| <= 36;
47 mpz_export and mpz_import support only NAILS = 0.
49 The REALLOC_FUNC and FREE_FUNC registered with
50 mp_set_memory_functions does not get the correct size of the
51 allocated block in the corresponding argument. mini-gmp always
52 passes zero for these rarely used arguments.
54 The implementation is a single file, mini-gmp.c.
56 The performance target for mini-gmp is to be at most 10 times slower
57 than the real GMP library, for numbers of size up to a few hundred
58 bits. No asymptotically fast algorithms are included in mini-gmp, so
59 it will be many orders of magnitude slower than GMP for very large
62 You should never "install" mini-gmp. Applications can either just
63 #include mini-gmp.c (but then, beware that it defines several macros
64 and functions outside of the advertised interface). Or compile
65 mini-gmp.c as a separate compilation unit, and use the declarations in
68 The tests subdirectory contains a testsuite. To use it, you need GMP
69 and GNU make. Just run make check in the tests directory. If the
70 hard-coded compiler settings are not right, you have to either edit the
71 Makefile or pass overriding values on the make command line (e.g.,
72 make CC=cc check). Testing is not (yet) as thorough as for the real
75 The current version was put together by Niels Möller
76 <nisse@lysator.liu.se>, with a fair amount of copy-and-paste from the