PHPackages                             lumisys/bcmath\_compat - 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. lumisys/bcmath\_compat

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

lumisys/bcmath\_compat
======================

PHP 5.x/7.x polyfill for bcmath extension

1.0.5.2(6mo ago)017.8k↓100%MITPHP

Since May 26Pushed 6mo agoCompare

[ Source](https://github.com/LumiSys/bcmath_compat)[ Packagist](https://packagist.org/packages/lumisys/bcmath_compat)[ RSS](/packages/lumisys-bcmath-compat/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (10)Used By (0)

bcmath\_compat
==============

[](#bcmath_compat)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/79951322f33442e1a9eaf937e466cd3ab37c3f2a8902e986d2d209b9723cb249/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7068707365636c69622f62636d6174685f636f6d7061742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/phpseclib/bcmath_compat)

PHP 5.x/7.x polyfill for bcmath extension

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

[](#installation)

With [Composer](https://getcomposer.org/):

```
$ composer require phpseclib/bcmath_compat
```

Installation On Heroku
----------------------

[](#installation-on-heroku)

bcmath\_compat does not install the normal way on Heroku / Composer &lt; 2.0 because Heroku [uses modified composer.json's](https://github.com/phpseclib/bcmath_compat/issues/1#issuecomment-573112000). Composer 2 [makes this a non-issue](https://github.com/phpseclib/bcmath_compat/issues/1#issuecomment-618951036).

In light of this the way to install this on Heroku with Composer &lt; 2.0 is to do the following:

```
$ composer require phpseclib/bcmath_compat:1.0.4
```

Limitations
-----------

[](#limitations)

- `extension_loaded('bcmath')`

    bcmath\_compat cannot make this return true. The recommended remediation is to not do this.
- `ini_set('bcmath.scale', ...)`

    You cannot set configuration options for extensions that are not installed. If you do `ini_set('bcmath.scale', 5)` on a system without bcmath installed then `ini_get('bcmath.scale')` will return `false`. It's similar to what happens when you do `ini_set('zzz', 5)` and then `ini_get('zzz')`. You'll get `false` back.

    The recommended remediation to doing `ini_set('bcmath.scale', ...)` is to do `bcscale(...)`. The recommended remediation for doing `ini_get` is (if you're using PHP &gt;= 7.3.0) to do `bcscale()` or (if you're using PHP &lt; 7.3.0) to do `max(0, strlen(bcadd('0', '0')) - 2)`.

    Note that `ini_get` always returns a string whereas the recommended remediations return integers.

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance70

Regular maintenance activity

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 94.1% 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 ~292 days

Recently: every ~528 days

Total

9

Last Release

200d ago

### Community

Maintainers

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

---

Top Contributors

[![terrafrost](https://avatars.githubusercontent.com/u/214474?v=4)](https://github.com/terrafrost "terrafrost (32 commits)")[![MIvanIsten](https://avatars.githubusercontent.com/u/1678373?v=4)](https://github.com/MIvanIsten "MIvanIsten (2 commits)")

---

Tags

polyfillBigIntegermathbigdecimalbcmath

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/lumisys-bcmath-compat/health.svg)

```
[![Health](https://phpackages.com/badges/lumisys-bcmath-compat/health.svg)](https://phpackages.com/packages/lumisys-bcmath-compat)
```

###  Alternatives

[phpseclib/bcmath_compat

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

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

Arbitrary-precision arithmetic library

2.1k504.0M276](/packages/brick-math)[symfony/polyfill-mbstring

Symfony polyfill for the Mbstring extension

7.8k1.2B515](/packages/symfony-polyfill-mbstring)[phpseclib/mcrypt_compat

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

28029.7M34](/packages/phpseclib-mcrypt-compat)[prestashop/decimal

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

178.2M5](/packages/prestashop-decimal)[aza/math

AzaMath - Anizoptera CMF mathematic component. Arbitrary precision arithmetic (for huge integers; BCMath wrapper) and universal convertor between positional numeral systems (supported bases from 2 to 62 inclusive, and systems with custom alphabet; pure PHP realisation, can use GMP and core PHP functions for speed optimization).

1921.9k1](/packages/aza-math)

PHPackages © 2026

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