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

2.0.0(1y ago)06MITPHPPHP ^8.1

Since Nov 17Pushed 1y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (7)Versions (4)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)[![Build](https://camo.githubusercontent.com/bee20619a2f5d90f701cbf0e743bbeec61b0307f173bfce3bd68ace5527b99e8/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f6275696c642f672f7768616c6c7973736f6e2f6d6f6e65792d707265636973696f6e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/whallysson/money-precision)[![Quality Score](https://camo.githubusercontent.com/c3e2b7c2a86b1db7baef1293caa8a785148c2b7f0ed30824d22edaae5a5937b2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7768616c6c7973736f6e2f6d6f6e65792d707265636973696f6e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/whallysson/money-precision)[![Total Downloads](https://camo.githubusercontent.com/d61d8487f93dd17ee5bd52a5acab7b0b0e86326f074298355c5e2a725199088a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7768616c6c7973736f6e2f6d6f6e65792d707265636973696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/whallysson/money-precision)

**MoneyPrecision** is a PHP library designed to handle monetary values with precision, ensuring accurate conversions, formatting, and arithmetic operations. With support for multiple currencies, it is ideal for applications that demand reliability in financial calculations.

---

🚀 Features
----------

[](#-features)

- Conversions between integer and decimal values ​​while maintaining precision.
- Arithmetic operations (addition, subtraction, multiplication and division) with high accuracy.
- Comparisons between monetary values.
- Support for multiple currencies with custom formatting.
- Intuitive and extensible API.
- **Precise Conversion**:

    - Integer to Decimal and vice-versa.
    - Handles trailing zeros (e.g., `5660 -> 56.60`).
- **Arithmetic Operations**:

    - Addition, subtraction, multiplication, and division.
    - Guaranteed accuracy with `bcmath`.
- **Currency Support**:

    - Easily extendable for multiple currencies.
    - Includes BRL, USD, and EUR by default.
- **Comparison**:

    - Compare monetary values using `equals`, `greaterThan`, and `lessThan`.
- **Customizable Formatting**:

    - Flexible formatting with symbols, separators, and positioning.

---

🛠 Installation
--------------

[](#-installation)

Install **MoneyPrecision** with [Composer](https://getcomposer.org/):

```
"whallysson/money-precision": "^2.0"
```

or run

```
composer require whallysson/money-precision
```

📖 Documentation
---------------

[](#-documentation)

For detailed information and examples, visit the [documentation](https://github.com/whallysson/money-precision/blob/main/README.md).

📚 Usage
-------

[](#-usage)

### Basic Conversions

[](#basic-conversions)

```
