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

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

phpseclib/bcmath\_compat
========================

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

2.0.3(1y ago)16720.7M↑12.6%6[1 PRs](https://github.com/phpseclib/bcmath_compat/pulls)12MITPHP

Since May 26Pushed 1y ago1 watchersCompare

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

READMEChangelog (10)Dependencies (3)Versions (17)Used By (12)

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

[](#bcmath_compat)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![CI Status](https://github.com/phpseclib/bcmath_compat/actions/workflows/ci.yml/badge.svg?branch=master&event=push "CI Status")](https://github.com/phpseclib/bcmath_compat/actions/workflows/ci.yml?query=branch%3Amaster)

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

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

[](#installation)

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

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

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

50

—

FairBetter than 96% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity62

Solid adoption and visibility

Community20

Small or concentrated contributor base

Maturity67

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

Recently: every ~26 days

Total

16

Last Release

711d ago

Major Versions

1.0.6 → 2.0.02020-12-22

1.0.7 → 2.0.12021-12-16

1.0.8 → 2.0.22024-02-21

1.0.9 → 2.0.32024-06-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/1214cf33299ce51f30c9c199cf3b55e8630cc16d5df714c551407088937e9988?d=identicon)[terrafrost](/maintainers/terrafrost)

---

Top Contributors

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

---

Tags

bcmathbcmath-polyfillphppolyfillBigIntegermathbigdecimalbcmath

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[brick/math

Arbitrary-precision arithmetic library

2.1k504.0M277](/packages/brick-math)[phpseclib/mcrypt_compat

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

28129.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)[phpmath/biginteger

A PHP library to work with big integers.

235.8k1](/packages/phpmath-biginteger)

PHPackages © 2026

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