Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Angourimath | 624 | 1 | 6 months ago | 13 | December 03, 2021 | 127 | mit | C# | ||
New open-source cross-platform symbolic algebra library for C# and F#. Can be used for both production and research purposes. | ||||||||||
Calc | 260 | 5 days ago | 8 | other | C | |||||
C-style arbitrary precision calculator | ||||||||||
Javascript Biginteger | 181 | 12 | 6 | 4 years ago | 4 | April 15, 2014 | 3 | mit | JavaScript | |
A big integer library for JavaScript | ||||||||||
Imath | 102 | 4 months ago | 5 | other | C | |||||
Arbitrary precision integer and rational arithmetic library | ||||||||||
Nim Stint | 69 | 16 hours ago | August 20, 2022 | 19 | apache-2.0 | Nim | ||||
Stack-based arbitrary-precision integers - Fast and portable with natural syntax for resource-restricted devices. | ||||||||||
Bcmath Extended | 67 | 18 | 11 | 4 months ago | 24 | February 09, 2022 | mit | PHP | ||
Extends php BCMath lib for missing functions like floor, ceil, round, abs, min, max, rand for big numbers. Also wraps existing BCMath functions. | ||||||||||
Fermat | 61 | 3 | 7 months ago | 7 | June 27, 2021 | 4 | gpl-2.0 | PHP | ||
A library providing math and statistics operations for numbers of arbitrary size. | ||||||||||
Math | 47 | 13 days ago | 1 | mit | JavaScript | |||||
Complex special functions and common mathematical operations in JavaScript | ||||||||||
Polynomialroots.jl | 47 | a month ago | 10 | other | Julia | |||||
Fast complex polynomial root finder, with support for arbitrary precision calculations | ||||||||||
Cldr Engine | 39 | 1 | 7 | 2 months ago | 170 | April 18, 2022 | 1 | apache-2.0 | TypeScript | |
Internationalization and localization in Typescript with Unicode CLDR, batteries included |
libmathxcore
- A C library for arbitrary-precision arithmeticlibmathxcore
is a library for high-precision integer and floating-point arithmetic.
git clone https://github.com/strandfield/libmathxcore.git
cd libmathxcore
mkdir build && cd build
cmake ..
make
The library provides three types:
mx_int_t
: arbitrary precision integer arithmeticmx_rat_t
: rational numbersmx_float_t
: floating-point numbers (the radix is a power of 2)Depending on the type, you will use functions prefixed with either int_*
,
rat_*
, or float_*
.
For example, int_init
is used to initialize integers while rat_add
adds
two rational numbers.
#include "mathx/core/integer.h"
#include "mathx/core/rational.h"
A rational number is stored as two mx_int_t
without any common factors
(rational numbers are always stored in reduced form).
The sign of a rational number is stored in its numerator (the denominator is always positive).
#include "mathx/core/float.h"
A floating-point number x
is basically a signed integer m
and an exponent n
.
The represented number is: x = m * B^n
with B
a power of two
(currently 2^8
, 2^16
or ^2^32
).
Since not all decimal numbers can be represented exactly in this form
(for example 0.1
has no finite binary form), and additional prec
field
describe on how many limbs the result are to be computed (see example below).
The famous constant pi
can be computed with the following code.
mx_float_t pi;
// We want to compute pi on 128 bytes.
float_init_prec(&pi, float_prec_bytes(128));
float_assign_pi(&pi);
float_print(&pi);
float_clear(&pi);
On my machine, this prints:
3141592653589793238462643383279502884197169
3993751058209749445923078164062862089986280
3482534211706798214808651328230664709384460
9550582231725359408128481117450284102701938
5211055596446229489549303819644288109756659
3344612847564823378678316527120190914564856
6923460348610454326648213393607260249141273
72458e-305
We got an approximation of pi
to 305 decimal places.
All digits are correct, but the result is not correctly rounded.
This is because all operations are done in a binary base and
are truncated for performance.