PHPackages                             maba/math - 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. maba/math

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

maba/math
=========

PHP library for arbitrary precision mathematics

v1.0.1(11y ago)369.7k↓37.5%3[1 PRs](https://github.com/mariusbalcytis/math/pulls)2MITPHPPHP &gt;=5.3.2

Since Sep 20Pushed 7y ago1 watchersCompare

[ Source](https://github.com/mariusbalcytis/math)[ Packagist](https://packagist.org/packages/maba/math)[ RSS](/packages/maba-math/feed)WikiDiscussions master Synced 1mo ago

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

PHP Math library
================

[](#php-math-library)

PHP library for arbitrary precision mathematics.

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

[](#installation)

```
composer require maba/math
```

Why
---

[](#why)

```
var_dump(intval(9223372036854775807 + 1));
// int(-9223372036854775808)

var_dump(5.2 * 3 === 15.6);
// bool(false)

var_dump((8 + 92233720368547750) * 1500 / 1500 - 92233720368547750);
// float(16)
```

Usage
-----

[](#usage)

```
use Maba\Component\Math\BcMath;
use Maba\Component\Math\Math;
use Maba\Component\Math\NumberFormatter;

$basicMathImplementation = new BcMath();
$math = new Math($basicMathImplementation);

var_dump($math->add('9223372036854775807', '1'));
// string(40) "9223372036854775808.00000000000000000000"
var_dump($math->isEqual($math->mul('5.2', '3'), '15.6'));
// bool(true)
var_dump($math->sub($math->div($math->mul($math->add('8', '92233720368547750'), '1500'), '1500'), '92233720368547750'));
// string(22) "8.00000000000000000000"

$result = $math->pow($math->mul('3.141592653589793', '2.71828182845904523536'), 13);

$formatter = new NumberFormatter($math);
echo $formatter->formatNumber($result, 4, '.', ' '); // prints 1 284 625 710 591.2256
```

`BcMath` class uses `bcmath` functions. If you need to use some other arbitrary precision math implementation, implement `BasicMathInterface`.

Running tests
-------------

[](#running-tests)

[![Travis status](https://camo.githubusercontent.com/3df5fc4c305917f32630b764703a0cdb194bed5216233198ae1e8a67f1151c61/68747470733a2f2f7472617669732d63692e6f72672f6d617269757362616c63797469732f6d6174682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mariusbalcytis/math)[![Coverage Status](https://camo.githubusercontent.com/ba2fe4e5db4f77146e897d56e912f5a81453709d08a1515082ec1da73c06ad53/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6d617269757362616c63797469732f6d6174682f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/mariusbalcytis/math?branch=master)

```
composer install
vendor/bin/phpunit
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

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

Total

2

Last Release

4258d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e131c9aa5f5a4fc3cc2f5e01b377ef33bbc3468acc95ff890fc6e8353d9cf67?d=identicon)[mariusbalcytis](/maintainers/mariusbalcytis)

---

Top Contributors

[![mariusbalcytis](https://avatars.githubusercontent.com/u/1590072?v=4)](https://github.com/mariusbalcytis "mariusbalcytis (5 commits)")

---

Tags

arbitrary-precisionbcmathbigdecimalmathphpmathematicsmathbcmath

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/maba-math/health.svg)

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

###  Alternatives

[brick/math

Arbitrary-precision arithmetic library

2.1k504.0M277](/packages/brick-math)[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)[markbaker/complex

PHP Class for working with complex numbers

1.7k283.1M38](/packages/markbaker-complex)[markbaker/matrix

PHP Class for working with matrices

1.5k279.7M38](/packages/markbaker-matrix)[phpseclib/bcmath_compat

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

16720.7M17](/packages/phpseclib-bcmath-compat)[prestashop/decimal

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

178.2M5](/packages/prestashop-decimal)

PHPackages © 2026

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