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

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

spryker/decimal
===============

PHP decimal handling as value object

1.2.1(2mo ago)231.3k↓50%8[2 PRs](https://github.com/spryker/decimal-object/pulls)MITPHPPHP &gt;=8.3CI passing

Since Oct 15Pushed 2mo ago59 watchersCompare

[ Source](https://github.com/spryker/decimal-object)[ Packagist](https://packagist.org/packages/spryker/decimal)[ RSS](/packages/spryker-decimal/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (3)Versions (8)Used By (0)

Decimal Object
==============

[](#decimal-object)

[![Build Status](https://github.com/spryker/decimal-object/workflows/CI/badge.svg?branch=master)](https://github.com/spryker/decimal-object/actions?query=workflow%3ACI+branch%3Amaster)[![codecov](https://camo.githubusercontent.com/90a6172664acf333127cf1401966652a77e0148fb8083011d0b7de2c25341286/68747470733a2f2f636f6465636f762e696f2f67682f737072796b65722f646563696d616c2d6f626a6563742f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d4c3174684642396e4f47)](https://codecov.io/gh/spryker/decimal-object)[![Latest Stable Version](https://camo.githubusercontent.com/12e2df75fe4727a25732efe1e24bb5ea50265fc502424429b93a2b1e01d6ae76/68747470733a2f2f706f7365722e707567782e6f72672f737072796b65722f646563696d616c2d6f626a6563742f762f737461626c652e737667)](https://packagist.org/packages/spryker/decimal-object)[![Minimum PHP Version](https://camo.githubusercontent.com/9c50dc780fa576f5c39b4feff00c05345c1471be0808881a09e750b91220dc54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e332d3838393242462e737667)](https://php.net/)[![PHPStan](https://camo.githubusercontent.com/f60d96f7c2579690ab6dfa8918f777fe93a02a92301c661eb38a85861a92b780/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230382d627269676874677265656e2e7376673f7374796c653d666c6174)](https://phpstan.org/)[![License](https://camo.githubusercontent.com/18ad9495fba1ef1dcd607d2e8baadbdedb726c3d1fd922516b7d3e29a54eda60/68747470733a2f2f706f7365722e707567782e6f72672f737072796b65722f646563696d616c2d6f626a6563742f6c6963656e7365)](https://packagist.org/packages/spryker/decimal-object)

Decimal value object for PHP.

Background
----------

[](#background)

When working with monetary values, normal data types like int or float are not suitable for exact arithmetic. Try out the following in PHP:

```
var_dump(0.1 + 0.2);        // float(0.3)
var_dump(0.1 + 0.2 - 0.3);  // float(5.5511151231258E-17)
```

Handling them as string is a workaround, but as value object you can more easily encapsulate some of the logic.

### Alternatives

[](#alternatives)

Solutions like  require a PHP extension (would make it faster, but also more difficult for some servers to be available). For details see the [wiki](https://github.com/spryker/decimal-object/wiki).

Features
--------

[](#features)

- Super strict on precision/scale. Does not lose significant digits on its own. You need to `trim()` for this manually.
- Speaking API (no le, gt methods).
- Basic math operations and checks supported.
- Immutability.
- Handle very large and very small numbers.

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

[](#installation)

### Requirements

[](#requirements)

- `bcmath` PHP extension enabled

### Composer (preferred)

[](#composer-preferred)

```
composer require spryker/decimal-object

```

Usage
-----

[](#usage)

See [Documentation](/docs) for more details.

### Implementations

[](#implementations)

The following libraries are using the `Decimal` value object:

- [dereuromark/cakephp-decimal](https://github.com/dereuromark/cakephp-decimal) as decimal type replacement for CakePHP ORM.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance83

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 68.3% 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 ~464 days

Recently: every ~570 days

Total

6

Last Release

87d ago

Major Versions

0.1.0 → 1.0.02019-11-25

PHP version history (3 changes)0.1.0PHP &gt;=7.1

1.0.1PHP &gt;=7.2

1.2.0PHP &gt;=8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10738957?v=4)[Spryker Bot](/maintainers/spryker-bot)[@spryker-bot](https://github.com/spryker-bot)

---

Top Contributors

[![dereuromark](https://avatars.githubusercontent.com/u/39854?v=4)](https://github.com/dereuromark "dereuromark (71 commits)")[![m7moud](https://avatars.githubusercontent.com/u/3217954?v=4)](https://github.com/m7moud "m7moud (7 commits)")[![vol4onok](https://avatars.githubusercontent.com/u/5063777?v=4)](https://github.com/vol4onok "vol4onok (7 commits)")[![olhalivitchuk](https://avatars.githubusercontent.com/u/77281282?v=4)](https://github.com/olhalivitchuk "olhalivitchuk (5 commits)")[![gechetspr](https://avatars.githubusercontent.com/u/42143273?v=4)](https://github.com/gechetspr "gechetspr (4 commits)")[![a-sabaa](https://avatars.githubusercontent.com/u/1667759?v=4)](https://github.com/a-sabaa "a-sabaa (3 commits)")[![spryker-bot](https://avatars.githubusercontent.com/u/10738957?v=4)](https://github.com/spryker-bot "spryker-bot (2 commits)")[![asmarovydlo](https://avatars.githubusercontent.com/u/15832795?v=4)](https://github.com/asmarovydlo "asmarovydlo (2 commits)")[![spryker-release-bot](https://avatars.githubusercontent.com/u/26904324?v=4)](https://github.com/spryker-release-bot "spryker-release-bot (1 commits)")[![tamasnyulas](https://avatars.githubusercontent.com/u/3429362?v=4)](https://github.com/tamasnyulas "tamasnyulas (1 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[eventsauce/eventsauce

A pragmatic event sourcing library for PHP with a focus on developer experience.

8632.1M47](/packages/eventsauce-eventsauce)[mastani/laravel-google-static-map

Laravel Google Static Map Generator

471.5M8](/packages/mastani-laravel-google-static-map)[web3p/ethereum-util

A collection of utility functions for Ethereum written in PHP.

30420.2k26](/packages/web3p-ethereum-util)[bomo/ical-bundle

Create ics url or file for Symfony 2, 3, 4 and 5

19288.2k](/packages/bomo-ical-bundle)[jrfnl/php-cast-to-type

PHP Class to consistently cast variables to a specific type.

13251.5k4](/packages/jrfnl-php-cast-to-type)[t1st3/php-json-minify

1470.9k](/packages/t1st3-php-json-minify)

PHPackages © 2026

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