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

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

joaomfrebelo/decimal
====================

php class to work with Decimal numbers

4.0.0(4y ago)028012MITPHPPHP ^8.0CI failing

Since Feb 27Pushed 3y ago1 watchersCompare

[ Source](https://github.com/joaomfrebelo/Decimal)[ Packagist](https://packagist.org/packages/joaomfrebelo/decimal)[ Docs](https://github.com/joaomfrebelo/Decimal)[ RSS](/packages/joaomfrebelo-decimal/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (5)Versions (10)Used By (2)

Decimal
=======

[](#decimal)

Decimal is a library do work with decimals in PHP. This library has classes to signed and unsigned decimals.

Start on version 4.0 the round method can be high precision or standard mode, by default is set to standard mode.

The standard mode round precision the decimal using only the first digit after the last digit of precision, the high precision use all decimals digits.

Example
-------

[](#example)

```
use Rebelo\Decimal\RoundMode;
use Rebelo\Decimal\Decimal;

$decimal = new Decimal(9.9, 4, new RoundMode(RoundMode::HALF_UP));
$result = $decimal->plus(new Decimal(0.1, 2));
$float = $result->valueOf();

// Simple initialization
$decimal = new Decimal(9.9, 4);

// Full initialization set the RoundMode and precion round mode
$decimal = new Decimal(9.9, 4, new RoundMode(RoundMode::HALF_UP), true);

// Difference between standard mode round precision and high precision
// Standard mode
new Decimal(12571.674647, 2, null, false); // will be round to 12571.67
// high precision mode
new Decimal($value, 2, null, true); // will be12571.68
```

Install
-------

[](#install)

Via Composer

```
$ composer require joaomfrebelo/Decimal
```

License
-------

[](#license)

Copyright (c) 2019 João M F Rebelo

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity71

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

Recently: every ~113 days

Total

9

Last Release

1608d ago

Major Versions

1.0.1 → 2.0.02020-09-06

2.0.4 → 3.0.02021-02-07

3.0.0 → 4.0.02021-12-17

PHP version history (4 changes)1.0.0PHP ^7.2

2.0.0PHP ^7.4

2.0.4PHP ^7.4 || 8.0

3.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/909b2a0bdc281c7125fc264a04f0da1538f16cbad859501919565f8e21dde18d?d=identicon)[joaomfrebelo](/maintainers/joaomfrebelo)

---

Top Contributors

[![joaomfrebelo](https://avatars.githubusercontent.com/u/2965955?v=4)](https://github.com/joaomfrebelo "joaomfrebelo (14 commits)")

---

Tags

decimal

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[brick/math

Arbitrary-precision arithmetic library

2.1k504.0M277](/packages/brick-math)[php-decimal/php-decimal

Correctly-rounded arbitrary precision decimal floating point

781.0M9](/packages/php-decimal-php-decimal)[prestashop/decimal

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

178.2M5](/packages/prestashop-decimal)[rtlopez/decimal

An object oriented immutable arbitrary-precision arithmetic library for PHP

27262.8k2](/packages/rtlopez-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)[danog/phpstruct

PHP implementation of python's struct module.

1110.1k](/packages/danog-phpstruct)

PHPackages © 2026

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