PHPackages                             richardds/big-integer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. richardds/big-integer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

richardds/big-integer
=====================

Library for big integer manipulation

0.1.0(5y ago)014MITPHPPHP ^7.2 || ^8.0

Since Jan 11Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Richardds/BigInteger)[ Packagist](https://packagist.org/packages/richardds/big-integer)[ RSS](/packages/richardds-big-integer/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (4)Used By (0)

BigInteger [![MIT Licence](https://camo.githubusercontent.com/409aebe7d91bface5998b12e2f2bbd90f41f9275a8c47547f18a236693b866da/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7269636861726464732f426967496e7465676572)](https://camo.githubusercontent.com/409aebe7d91bface5998b12e2f2bbd90f41f9275a8c47547f18a236693b866da/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7269636861726464732f426967496e7465676572) [![Github Issues](https://camo.githubusercontent.com/0c3c92d981612027696d40f7e26c56a392f1cc4f176ef09c1e15e1564f3952d8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f7269636861726464732f426967496e74656765722e737667)](http://github.com/richardds/BigInteger/issues)
=================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#biginteger--)

PHP OOP library for fast big integer manipulation made as a wrapper around GMP library. The library is not converting the numbers into a string but uses GMP resources, which comes with significant speed improvement compared to other libraries. The library has no external dependencies.

### General requirements

[](#general-requirements)

- `php-7.2` and higher
- `php-gmp` library

### How to install GMP on Apline Linux

[](#how-to-install-gmp-on-apline-linux)

```
RUN apk add --update --no-cache gmp
RUN apk add --update --no-cache --virtual .phpize-deps $PHPIZE_DEPS autoconf g++ make gmp-dev && \
    docker-php-ext-install gmp && \
    apk del .phpize-deps $PHPIZE_DEPS autoconf g++ make gmp-dev
```

Examples
--------

[](#examples)

Majority of the methods accept `BigInteger` object, `string` or `int`. The `BigInteger` object uses GMP resource. Therefore, there is no slow string conversion on every operation.

```
use Richardds\BigInteger\BigInteger;
use Richardds\BigInteger\Utils as BigIntegerUtils;

$g = BigInteger::fromInt(2);
$e = BigInteger::fromString("");
$m = BigInteger::fromString("");
$c = $g->powMod($e, $m);

$p = BigInteger::fromBuffer("");
$z = BigInteger::fromString("");

$x = $g->powMod($p, $m)
       ->mul($z->sub(BigInteger::one()))
       ->mod($m);

$a = BigInteger::fromString("");
$b = BigInteger::fromString("");
$gcd = $a->gcd($b);
$gcd = BigIntegerUtils::gcd($a, $b);
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

3

Last Release

1951d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e2b697b84cf0a71279457ab1b4627dc397292bbe25862e6450632cfdc00e7862?d=identicon)[Richardds](/maintainers/Richardds)

---

Top Contributors

[![Richardds](https://avatars.githubusercontent.com/u/12068816?v=4)](https://github.com/Richardds "Richardds (8 commits)")

---

Tags

bigintegercomposer-libraryphpBigIntegermathbigdecimalbignumber

### Embed Badge

![Health badge](/badges/richardds-big-integer/health.svg)

```
[![Health](https://phpackages.com/badges/richardds-big-integer/health.svg)](https://phpackages.com/packages/richardds-big-integer)
```

###  Alternatives

[brick/math

Arbitrary-precision arithmetic library

2.1k504.0M277](/packages/brick-math)[phpseclib/bcmath_compat

PHP 5.x-8.x polyfill for bcmath extension

16720.7M17](/packages/phpseclib-bcmath-compat)[markrogoyski/math-php

Math Library for PHP. Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra

2.4k7.1M40](/packages/markrogoyski-math-php)[rubix/tensor

A library and extension that provides objects for scientific computing in PHP.

2751.4M5](/packages/rubix-tensor)[prestashop/decimal

Object-oriented wrapper/shim for BC Math PHP extension. Allows for arbitrary-precision math operations.

178.2M5](/packages/prestashop-decimal)[phpmath/biginteger

A PHP library to work with big integers.

235.8k1](/packages/phpmath-biginteger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
