PHPackages                             krowinski/bcmath-extended - 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. krowinski/bcmath-extended

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

krowinski/bcmath-extended
=========================

Extends php BCMath lib for missing functions like floor, ceil, round, abs, min, max, rand for big numbers. Also wraps existing BCMath functions. (more http://php.net/manual/en/book.bc.php) Supports scientific notations

8.1.0(4mo ago)801.1M↓39.4%12[1 issues](https://github.com/krowinski/bcmath-extended/issues)16MITPHPPHP ^8.4CI passing

Since Mar 20Pushed 4mo ago5 watchersCompare

[ Source](https://github.com/krowinski/bcmath-extended)[ Packagist](https://packagist.org/packages/krowinski/bcmath-extended)[ RSS](/packages/krowinski-bcmath-extended/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (6)Versions (29)Used By (16)

bcmath-extended
===============

[](#bcmath-extended)

[![PHP Tests](https://github.com/krowinski/bcmath-extended/actions/workflows/tests.yml/badge.svg)](https://github.com/krowinski/bcmath-extended/actions/workflows/tests.yml)[![Code Coverage](https://raw.githubusercontent.com/krowinski/bcmath-extended/master/badge-coverage.svg)](https://github.com/krowinski/bcmath-extended/actions)[![Latest Stable Version](https://camo.githubusercontent.com/d746a23b8028d92f028ff36f4965ced4595b87fe406ee0cce4bd445c18b99798/68747470733a2f2f706f7365722e707567782e6f72672f6b726f77696e736b692f62636d6174682d657874656e6465642f762f737461626c65)](https://packagist.org/packages/krowinski/bcmath-extended)[![Total Downloads](https://camo.githubusercontent.com/3042020f96ab61e0eaea14dbcc529fff8ae00775d2c5eb24dc6a1af6b5068637/68747470733a2f2f706f7365722e707567782e6f72672f6b726f77696e736b692f62636d6174682d657874656e6465642f646f776e6c6f616473)](https://packagist.org/packages/krowinski/bcmath-extended)[![License](https://camo.githubusercontent.com/68e967663e4ea7e8618567614d7c204d6fd9c306080e1295f4ac56685727b48e/68747470733a2f2f706f7365722e707567782e6f72672f6b726f77696e736b692f62636d6174682d657874656e6465642f6c6963656e7365)](https://packagist.org/packages/krowinski/bcmath-extended)

Extends php BCMath lib for missing functions like abs, min, max, rand, fact, log for big numbers. Handles scientific notation like 1.0E+35 to be used with BCMath. Also wraps existing BCMath functions. (more )

Installation
============

[](#installation)

```
composer require krowinski/bcmath-extended
```

Features
========

[](#features)

- config
    - setTrimTrailingZeroes - disable|enable trailing zeros (default trimming is enabled)
- new tool methods
    - convertToNumber - converts scientific notation, string and int to [BcMath\\Number](https://www.php.net/manual/en/class.bcmath-number.php)
        - getScale - gets current global scale
        - getDecimalsLengthFromNumber - gets amount of decimals
        - hexdec - converting from hexadecimal to decimal
        - dechex - converting from decimal to hexadecimal
        - bin2dec - converting from binary to decimal
        - dec2bin - converting from decimal to binary
- new math functions
    - round
    - abs
    - rand
    - max
    - min
    - roundDown
    - roundUp
    - roundHalfEven
    - ceil
    - exp
    - log
    - fact
    - pow (supports fractional)
    - mod (supports fractional + scale)
        - bitwise operators
            - bitXor
            - bitOr
            - bitAnd
- proxy for [original functions](https://www.php.net/manual/en/book.bc.php)
- all functions supports scientific notation
- all functions are static, so it can be easily replaced by this lib

Info
====

[](#info)

As of 7.2 float can be passed to bcmod, but they don't return correct values (IMO)

I created bug for this in , but it was commented as documentation issue not a bug.

```
bcmod() doesn't use floor() but rather truncates towards zero,
which is also defined this way for POSIX fmod(), so that the
result always has the same sign as the dividend.  Therefore, this
is not a bug, but rather a documentation issue.

```

But I still will use floor not truncated for mod in this lib.

###  Health Score

67

—

FairBetter than 99% of packages

Maintenance77

Regular maintenance activity

Popularity54

Moderate usage in the ecosystem

Community31

Small or concentrated contributor base

Maturity91

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 85.2% 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 ~139 days

Recently: every ~499 days

Total

27

Last Release

125d ago

Major Versions

3.0.0 → 4.0.02018-08-03

4.2.1 → 5.0.02019-05-01

5.2.0 → 6.0.02020-09-11

6.0.1 → 7.0.02023-01-25

7.0.0 → 8.0.02025-06-25

PHP version history (5 changes)v1.0PHP &gt;=5.3

5.0.0PHP &gt;=7.1

6.0.1PHP ^7.1|^8.0

7.0.0PHP ^7.4|^8.0

8.0.0PHP ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1478555?v=4)[Kacper Rowiński](/maintainers/krowinski)[@krowinski](https://github.com/krowinski)

---

Top Contributors

[![krowinski](https://avatars.githubusercontent.com/u/1478555?v=4)](https://github.com/krowinski "krowinski (69 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (4 commits)")[![Sander-Toonen](https://avatars.githubusercontent.com/u/5106372?v=4)](https://github.com/Sander-Toonen "Sander-Toonen (2 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (2 commits)")[![gnutix](https://avatars.githubusercontent.com/u/310134?v=4)](https://github.com/gnutix "gnutix (1 commits)")[![mbezhanov](https://avatars.githubusercontent.com/u/785542?v=4)](https://github.com/mbezhanov "mbezhanov (1 commits)")[![aywan](https://avatars.githubusercontent.com/u/5608711?v=4)](https://github.com/aywan "aywan (1 commits)")[![jimmy4o4](https://avatars.githubusercontent.com/u/19704458?v=4)](https://github.com/jimmy4o4 "jimmy4o4 (1 commits)")

---

Tags

absarbitrary-precisionbignumberceilcomplex-numberscomposer-packagesdechedecimalsfloormathmoneyphprandscientific-notationphpmathArbitrary-precisionbignumberroundprecisionbcmathrandceilfloorabsbccomplex-numbersscientific-notation

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/krowinski-bcmath-extended/health.svg)

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

###  Alternatives

[brick/math

Arbitrary-precision arithmetic library

2.2k548.2M427](/packages/brick-math)[phpseclib/bcmath_compat

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

16821.5M27](/packages/phpseclib-bcmath-compat)[prestashop/decimal

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

178.9M9](/packages/prestashop-decimal)

PHPackages © 2026

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