Download the PHP package prestashop/decimal without Composer
On this page you can find all versions of the php package prestashop/decimal. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download prestashop/decimal
More information about prestashop/decimal
Files in prestashop/decimal
Package decimal
Short Description Object-oriented wrapper/shim for BC Math PHP extension. Allows for arbitrary-precision math operations.
License MIT
Homepage https://github.com/prestashop/decimal
Informations about the package decimal
Decimal
An object-oriented BC Math extension wrapper/shim.
Decimal offers a stateless, fluent object-oriented implementation of basic arbitrary-precision arithmetic, using BC Math if available.
You can find out more about floating point precision here.
Example:
Install
Via Composer
Usage reference
Quick links:
- Instantiation
- Addition
- Subtraction
- Multiplication
- Division
- Comparison
- Fixed precision
- Rounding
- Dot shifting
- Useful methods
Instantiation
Creates a new Decimal number.
There are two ways to instantiate a Decimal\DecimalNumber:
Addition
Returns the computed result of adding another number to the current one.
Examples:
Subtraction
Returns the computed result of subtracting another number to the current one.
Examples:
Multiplication
Returns the computed result of multiplying the current number with another one.
Examples:
Division
Returns the computed result of dividing the current number by another one, with up to a certain number of decimal positions (6 by default).
Examples:
Comparison
Returns the result of the comparison assertion.
Fixed precision
Returns the number as a string, optionally rounded, with an exact number of decimal positions.
Examples:
Rounding
Rounding behaves like toPrecision
, but provides "up to" a certain number of decimal positions
(it does not add trailing zeroes).
Examples:
Dot shifting
Creates a new copy of this number multiplied by 10^exponent
Examples:
Useful methods
Testing
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.