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(5mo ago)017.8k↓100%MITPHP

Since May 26Pushed 5mo 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 today

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 93% of packages

Maintenance73

Regular maintenance activity

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

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

153d 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.4M11](/packages/phpseclib-bcmath-compat)[brick/math

Arbitrary-precision arithmetic library

2.1k490.5M223](/packages/brick-math)[symfony/polyfill-mbstring

Symfony polyfill for the Mbstring extension

7.8k1.1B435](/packages/symfony-polyfill-mbstring)[paragonie/random_compat

PHP 5.x polyfill for random\_bytes() and random\_int() from PHP 7

8.2k645.3M371](/packages/paragonie-random-compat)[symfony/polyfill-intl-normalizer

Symfony polyfill for intl's Normalizer class and related functions

2.1k814.1M30](/packages/symfony-polyfill-intl-normalizer)[phpseclib/mcrypt_compat

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

28029.1M27](/packages/phpseclib-mcrypt-compat)

PHPackages © 2026

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