Download the PHP package egorsmkv-packagist/decimal without Composer
On this page you can find all versions of the php package egorsmkv-packagist/decimal. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download egorsmkv-packagist/decimal
More information about egorsmkv-packagist/decimal
Files in egorsmkv-packagist/decimal
Package decimal
Short Description An object oriented immutable arbitrary-precision arithmetic library for PHP
License MIT
Homepage https://github.com/egorsmkv/decimal
Informations about the package decimal
Decimal
An object oriented arbitrary precision arithmetic class for PHP (>5.3.3).
Installation
You can use Composer
To add this package as a local, per-project dependency to your project, simply add a dependency on rtlopez/decimal
to your project's composer.json
file. Here is a minimal example of a composer.json
file that just defines a dependency on Decimal
:
Features
The Decimal
class can be used for an arbitrary precision calculation. Main features are:
- Immutable result of each operation,
- The same result precision,
- Safe for finance calculations,
- Fluent interface,
- Many unit test (more than 1100 tests and 3700 assertions),
- Easy to use and install,
Why should I use it?
The Decimal
solve several inconveniences known in other solutions.
Float
is only an aproximation and have limited precision,Fixed-point
have limited size (64-bits on 64-bit system),- Pure
bcmath
cannot correctly round, only truncate, GMP
is not object-oriented
Usage
Creating objects with simple factory
Printing and formatting numbers
Arithmetics
Immutable
Comparisions
Rounding
Implementations
There are exists three internal implementations of this library.
RtLopez\DecimalBCMath
: (default)based on bcmath libraryRtLopez\DecimalFixed
: based on scaled integersRtLopez\DecimalFloat
: based on floats
Only BCMath
implementation works correctly in wide spectrum of numbers. All others can fail in many border cases. They was implemented only as proof of concept and you can using it only for your own risk.
The default implementation or precision can be changed by functions:
Licence
This library is distributed under MIT Licence.
Issue reporting or feature request
Coming soon.
TODO
- GMP implementation
Donation
BTC: 1Lopez7yPtbyjfLGe892JfheDFJMMt43tW LTC: LV3G3sJxz9AYpDMYUp8e1LCmerFYxVY3ak
All versions of decimal with dependencies
ext-bcmath Version *