Download the PHP package collab-corp/ez-math without Composer
On this page you can find all versions of the php package collab-corp/ez-math. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download collab-corp/ez-math
More information about collab-corp/ez-math
Files in collab-corp/ez-math
Package ez-math
Short Description A simple PHP wrapper math class for bcmath.
License MIT
Informations about the package ez-math
ez-math
A simple PHP wrapper math class for bcmath.
Installation
composer require collab-corp/ez-math
Use
Simply new up the class with the value and call the needed methods:
Decimal/Precision Numbers
Since the default decimal places is 2, it is important to keep in mind that if you are going to be working with low/precise numbers, be sure to scale your decimal places high enough before performing operations so that the bcmath functions calculate the final result correctly:
Method Chain
You can chain method calls as needed:
Set Decimal Places
By default, numbers scale to 2 decimal places. You can change to however many places you need to using the setPlaces
method if working with higher precision numbers:
Available Methods
setValue - set the value
setPlaces - round/scale to the specified decimal places
add - add a number to the value
subtract - subtract a number from the value
divide - divide the value by a number
multiply - multiply the value by a number
modulus - return the remainder after division(modulus)
toDecimalPercent - convert the value to a percent decimal
percentageOf - get the given percent of the number
squareRoot - get the square root of the value
Contribute
Contributions are always welcome in the following manner:
- Issue Tracker
- Pull Requests
- Collab Corp Discord (Will send invite as requested)
License
The project is licensed under the MIT license.
All versions of ez-math with dependencies
ext-bcmath Version ^8.0