Download the PHP package romainnorberg/residue without Composer
On this page you can find all versions of the php package romainnorberg/residue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download romainnorberg/residue
More information about romainnorberg/residue
Files in romainnorberg/residue
Package residue
Short Description Divide a float into several parts, with distribution of any remainder
License MIT
Informations about the package residue
Residue ⚖️
Divide a float into several parts, with distribution of any remainder.

Introduction
This dependency-free package provides a split
method to help you split float into parts, with the possible distribution of any remainder.
It is also possible to specify a rounding of the divided amount, for example rounding by 0.05.
🕹 Try out Residue on the online tester! »
Installation
You can install the package via composer:
Requirements
This package require >= PHP 7.4
Residue VS Brick\Money
This package does not deal with the notion of currency and being more basic, it is up to 40 times faster on basic operations than the brick/money package
Benchmarks: residue-vs-brick-money
Usage / examples
Basic split
Split with rounding (and remainder)
With remainder:
Split mode
SPLIT_MODE_ALLOCATE
is default mode and try to allocate the maximum of the value according to step.
SPLIT_MODE_EQUITY
mode try to allocate equally the maximum of the value according to step.
Generator
This package uses generator to reduce the memory used
With foreach statement (using generator):
To array:
Testing
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Romain Norberg
- All Contributors
- Illustration from Refactoring.Guru https://refactoring.guru/
License
The MIT License (MIT). Please see License File for more information.