PHPackages                             thehappycat/numerictools - 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. thehappycat/numerictools

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

thehappycat/numerictools
========================

PHP project to perform basic numeric operations

01[4 issues](https://github.com/TheHappyCat/NumericToolsPHP/issues)PHPCI passing

Since Aug 24Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/TheHappyCat/NumericToolsPHP)[ Packagist](https://packagist.org/packages/thehappycat/numerictools)[ RSS](/packages/thehappycat-numerictools/feed)WikiDiscussions master Synced 3mo ago

READMEChangelogDependenciesVersions (5)Used By (0)

[![php-big-integer](https://raw.githubusercontent.com/jpruiz114/php-big-integer/master/assets/mathematical.gif "Mathematical")](https://raw.githubusercontent.com/jpruiz114/php-big-integer/master/assets/mathematical.gif)

*php-big-integer* [![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE)
========================================================================================================================================================================================================================================================

[](#php-big-integer-)

A simple project created to handle large numeric operations in PHP!
-------------------------------------------------------------------

[](#a-simple-project-created-to-handle-large-numeric-operations-in-php)

Just like the normal numeric operations you would usually do, but with numbers of any size.

Requirements
------------

[](#requirements)

- **PHP:** 8.5, matching `composer.json` (`"php": "^8.5"`) and the `Dockerfile` image (`php:8.5-cli-bookworm`). The `^8.5` range allows compatible 8.x versions; it does not allow PHP 9.0 until you change that requirement.
- **Composer:** for installing dependencies when developing the library or running tests locally.
- **Docker (optional):** to build the image described under [Docker](#docker) instead of using a local PHP install.

Installation
------------

[](#installation)

### Via Composer (recommended)

[](#via-composer-recommended)

```
composer require jpruiz114/php-big-integer
```

### Manual installation

[](#manual-installation)

1. Clone this repository:

    ```
    git clone https://github.com/jpruiz114/php-big-integer.git
    cd php-big-integer
    ```
2. Install dependencies (runtime and **dev** dependencies such as PHPUnit):

    ```
    composer install
    ```

Docker
------

[](#docker)

The image uses **PHP 8.5** and **Composer**; install [Docker](https://docs.docker.com/get-docker/) locally. From the **repository root**:

**Build and run (default: PHPUnit via `composer test`)**

```
docker build -t php-big-integer .

docker run --rm -e XDEBUG_MODE=off php-big-integer
```

**Lock file**

`docker build` runs `composer install` using `composer.json` and `composer.lock`. If you change PHP or dev dependencies in `composer.json`, run `composer update` (or the relevant `composer require`) so `composer.lock` matches, commit the lock file, then rebuild. The same applies if the build fails with *lock file is not up to date* or a package *does not satisfy your constraint*.

**Refresh the lock file without local Composer** (writes `composer.lock` and `vendor/` into your project directory)

```
docker run --rm -v "$(pwd):/app" -w /app php:8.5-cli-bookworm bash -c \
  'apt-get update -qq && apt-get install -y --no-install-recommends curl unzip git -qq \
   && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
   && composer update --no-interaction --prefer-dist'
```

**Other commands**

```
# Shell in the container
docker run --rm -it -e XDEBUG_MODE=off php-big-integer sh

# HTML coverage under ./coverage on the host
docker run --rm -e XDEBUG_MODE=coverage -v "$(pwd)/coverage:/app/coverage" php-big-integer \
  ./vendor/bin/phpunit --coverage-html coverage/
```

For CPU-heavy commands like prime generation, keep Xdebug off for better performance:

```
docker run --rm -e XDEBUG_MODE=off php-big-integer php console/prime_generator.php generate 256
```

Quick start
-----------

[](#quick-start)

After `composer require jpruiz114/php-big-integer` (or this repository’s `composer install`), the `Integer` class is available in the `TheHappyCat\NumericTools` namespace.

```
