PHPackages                             whallysson/money-precision - 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. whallysson/money-precision

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

whallysson/money-precision
==========================

A simple library for precise monetary value handling and financial calculations

3.0.2(1mo ago)040MITPHPPHP &gt;=8.4

Since Nov 17Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/whallysson/money-precision)[ Packagist](https://packagist.org/packages/whallysson/money-precision)[ RSS](/packages/whallysson-money-precision/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (12)Versions (9)Used By (0)

MoneyPrecision
==============

[](#moneyprecision)

[![Maintainer](https://camo.githubusercontent.com/ba3200569409e72085b945f85a8f330b9cc2721bf789ab0d990b120d6b7998e0/687474703a2f2f696d672e736869656c64732e696f2f62616467652f6d61696e7461696e65722d407768616c6c7973736f6e2d626c75652e7376673f7374796c653d666c61742d737175617265)](https://www.linkedin.com/in/whallyssonavelino/?locale=en_US)[![Source Code](https://camo.githubusercontent.com/51025a9adcf5451ad19936351d6722156dc5842c1356e76aaeead9f2df3061ce/687474703a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d7768616c6c7973736f6e2f6d6f6e65792d2d707265636973696f6e2d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/whallysson/money-precision)[![PHP from Packagist](https://camo.githubusercontent.com/3768be0f7012074b81d3d72559eb62f80b2d55db4ab177a782a252254785a3a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7768616c6c7973736f6e2f6d6f6e65792d707265636973696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/whallysson/money-precision)[![Latest Version](https://camo.githubusercontent.com/007ec7a345146cc16a8771e1645aaeed64b4cc6a7d967a616ac855126093464b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7768616c6c7973736f6e2f6d6f6e65792d707265636973696f6e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/whallysson/money-precision/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Total Downloads](https://camo.githubusercontent.com/d61d8487f93dd17ee5bd52a5acab7b0b0e86326f074298355c5e2a725199088a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7768616c6c7973736f6e2f6d6f6e65792d707265636973696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/whallysson/money-precision)

**MoneyPrecision** is a PHP library for precise monetary values, explicit minor-unit conversion, currency-aware arithmetic, and locale-safe formatting.

Requirements
------------

[](#requirements)

- PHP `>=8.4`
- `ext-bcmath`

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

[](#installation)

```
composer require whallysson/money-precision:^3.0
```

Core Rules
----------

[](#core-rules)

- Use explicit constructors: `fromMinorUnits()`, `fromCents()`, `fromDecimal()`, and `parse()`.
- Do not pass floats for monetary values.
- Values are stored internally as integer minor units.
- Prefer `fromMinorUnits()` when code is currency-agnostic; `fromCents()` is a convenience alias for cent-based currencies.
- Money objects are immutable: arithmetic returns a new instance.
- Each value carries a currency, and arithmetic between different currencies throws.
- Multiplication and division require an explicit `RoundingMode`.
- `parse()` validates localized grouping strictly. Use `parseLenient()` only for trusted legacy input.
- Parsing and formatting are separate from calculation.

Usage
-----

[](#usage)

### Explicit Conversion

[](#explicit-conversion)

```
