PHPackages                             nickjbedford/decimal - 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. nickjbedford/decimal

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

nickjbedford/decimal
====================

A custom implementation of a Decimal class wrapping the BC library.

1.4.0(5mo ago)0207MITPHPPHP ^8.3

Since Mar 16Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/nickjbedford/decimal)[ Packagist](https://packagist.org/packages/nickjbedford/decimal)[ Docs](https://github.com/nickjbedford/decimal)[ RSS](/packages/nickjbedford-decimal/feed)WikiDiscussions main Synced today

READMEChangelog (7)Dependencies (1)Versions (29)Used By (0)

Yet Another Decimal Class
=========================

[](#yet-another-decimal-class)

This library implements the BC Math library into both an immutable and mutable subclass pair of classes named ImmutableDecimal and Decimal (mutable). The classes provide common methods such as simple arithmetic, equality and comparison methods as well as formatting and changes to decimal precision.

Example Usage
-------------

[](#example-usage)

### Immutable decimal arithmetic

[](#immutable-decimal-arithmetic)

```
$balance = new \YetAnother\ImmutableDecimal(144.52, 2);
$newBalance = $balance->plus(55.95);
$newBalance->printValue(); // "200.02"

if ($newBalance->greaterThanOrEqual(200)) {
    print("New balance is at or over $200.");
}
```

### Mutable decimal arithmetic (with helpers)

[](#mutable-decimal-arithmetic-with-helpers)

```
$amount = d4('129.9523'); // 4-digit precision (mutable) Decimal
$amount->add(87.5); // addition in place
$amount->printValue(); // "217.4523"

$remainder = $amount->modulus(5.5);
$remainder->printValue(); // "2.9523"
```

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance70

Regular maintenance activity

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity75

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

Recently: every ~60 days

Total

28

Last Release

169d ago

Major Versions

0.3.9 → 1.0.02023-11-16

PHP version history (3 changes)0.1PHP &gt;=7.4

1.0.0PHP &gt;=8.0

1.4.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10795658?v=4)[Nick Bedford](/maintainers/nickjbedford)[@nickjbedford](https://github.com/nickjbedford)

---

Top Contributors

[![nickjbedford](https://avatars.githubusercontent.com/u/10795658?v=4)](https://github.com/nickjbedford "nickjbedford (3 commits)")

---

Tags

decimalbcmath

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nickjbedford-decimal/health.svg)

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

###  Alternatives

[brick/math

Arbitrary-precision arithmetic library

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

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

16821.5M26](/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)[rtlopez/decimal

An object oriented immutable arbitrary-precision arithmetic library for PHP

27274.7k2](/packages/rtlopez-decimal)[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

801.1M24](/packages/krowinski-bcmath-extended)[php-decimal/php-decimal

Correctly-rounded arbitrary precision decimal floating point

781.1M10](/packages/php-decimal-php-decimal)

PHPackages © 2026

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