PHPackages                             021/numeric - 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. 021/numeric

ActiveLibrary

021/numeric
===========

A PHP library for working with precise numbers.

v1.1.0(3mo ago)03.4k↓31.6%1MITPHPPHP ^8.1|^8.2|^8.3CI passing

Since Mar 27Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/021-projects/numeric)[ Packagist](https://packagist.org/packages/021/numeric)[ RSS](/packages/021-numeric/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (8)Used By (1)

021/numeric
===========

[](#021numeric)

A PHP library to convenient work with arbitrary precision numbers.

[![Tests](https://github.com/021-projects/numeric/actions/workflows/tests-php-8.1.yml/badge.svg?branch=main)](https://github.com/021-projects/numeric/actions/workflows/tests-php-8.1.yml)[![Total Downloads](https://camo.githubusercontent.com/ca9ec1ea0cd5c16e0bac8eb55357869849796529e61d40bb22aa31779a6254fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f3032312f6e756d65726963)](https://packagist.org/packages/021/numeric)[![Latest Stable Version](https://camo.githubusercontent.com/715e390cd699781eb5203a42a7fb6ca2f2eefe924496ae51039f4808d606fe99/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f3032312f6e756d65726963)](https://packagist.org/packages/021/numeric)[![License](https://camo.githubusercontent.com/f9b7301d65e0bb3fa5360b084a7f91e5eb92bce680d2fd89b2686bdfb21839a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f3032312f6e756d65726963)](https://packagist.org/packages/021/numeric)

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

[](#requirements)

- PHP 8.1 or higher

Library is based on [Brick\\Math](https://github.com/brick/math) package:

> Although the library can work seamlessly on any PHP installation, it is highly recommended that you install the [GMP](https://www.php.net/manual/en/book.gmp.php) or [BCMath](https://www.php.net/manual/en/book.bc.php) extension to speed up calculations. The fastest available calculator implementation will be automatically selected at runtime.

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

[](#installation)

You can install the package via composer:

```
composer require 021/numeric
```

Usage
-----

[](#usage)

```
use function O21\Numeric\Helpers\num;

$number = num('123.456');

echo $number->add('0.544')->get();
```

### Calculations

[](#calculations)

All computational functions accept as an argument a value of one of the following types: `string`, `float`, `int`, `\O21\Numeric\Numeric`, `\Brick\Math\BigNumber`.

FunctionDescription`add`Adds a value to a number`sub`Subtracts a value from a number`mul`Multiplies a number by a value`div`Divides a number by a value### Comparisons

[](#comparisons)

All comparison functions accept as an argument a value of one of the following types: `string`, `float`, `int`, `\O21\Numeric\Numeric`, `\Brick\Math\BigNumber`.

FunctionDescription`equals`Checks if two values are equal. It returns true if the values are equal and false otherwise.`greaterThan`Compares two values and returns true if the first value is greater than the second one.`lessThan`Compares two values and returns true if the first value is less than the second one.`greaterThanOrEqual`Compares two values and returns true if the first value is greater than or equal to the second one.`lessThanOrEqual`Compares two values and returns true if the first value is less than or equal to the second one.### Formatting

[](#formatting)

FunctionDescription`positive`Returns a number represented as positive.`negative`Returns a number represented as negative.`scale`Converts a number to a given scale, using rounding if necessary.`get`Returns a number as string. By default removes trailing zeros. Use the `raw: true` option to disable this.`__toString`Returns a `get` function result### Helpers

[](#helpers)

Namespace: `O21\Numeric\Helpers`

FunctionDescription`num`Creates a new `Numeric` instance`num_min`Returns a minimum value from a given values. Support any of these types: `string`, `float`, `int`, `\O21\Numeric\Numeric`, `\Brick\Math\BigNumber``num_max`Returns a maximum value from a given values. Support any of these types: `string`, `float`, `int`, `\O21\Numeric\Numeric`, `\Brick\Math\BigNumber``to_bn`Converts any of these types `string`, `float`, `int`, `\O21\Numeric\Numeric`, `\Brick\Math\BigNumber` to `\Brick\Math\BigNumber`

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance82

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~115 days

Recently: every ~172 days

Total

7

Last Release

94d ago

PHP version history (2 changes)v1.0.0-RC1PHP ^8.1|^8.2

v1.0.0PHP ^8.1|^8.2|^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/850e7a3d7b73d4aca00b33bfd13c33b97a8bec35d3b889d50cc0eec3b26eb337?d=identicon)[021-projects](/maintainers/021-projects)

---

Top Contributors

[![021-projects](https://avatars.githubusercontent.com/u/20326979?v=4)](https://github.com/021-projects "021-projects (25 commits)")

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/021-numeric/health.svg)

```
[![Health](https://phpackages.com/badges/021-numeric/health.svg)](https://phpackages.com/packages/021-numeric)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[brick/money

Money and currency library

1.9k37.9M102](/packages/brick-money)[bavix/laravel-wallet

It's easy to work with a virtual wallet.

1.3k1.1M11](/packages/bavix-laravel-wallet)[illuminate/validation

The Illuminate Validation package.

18936.7M1.4k](/packages/illuminate-validation)[flow-php/etl

PHP ETL - Extract Transform Load - Abstraction

374468.4k51](/packages/flow-php-etl)

PHPackages © 2026

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