Download the PHP package tiny-blocks/math without Composer
On this page you can find all versions of the php package tiny-blocks/math. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tiny-blocks/math
More information about tiny-blocks/math
Files in tiny-blocks/math
Package math
Short Description Value Objects for handling arbitrary precision numbers.
License MIT
Homepage https://github.com/tiny-blocks/math
Informations about the package math
Math
- Overview
- Installation
- How to use
- License
- Contributing
Overview
Value Objects for handling arbitrary precision numbers.
Installation
How to use
The library exposes some concrete implementations for arbitrary precision numbers. Concrete implementations implement
the BigNumber
interface, which provides the behaviors for the respective BigNumbers.
Using the fromString method
With the fromString
method, a new instance of type BigNumber
is created from a valid string numeric value.
It is possible to set a scale
for the object through this method.
Always prefer to instantiate from a string, which supports an unlimited number of digits and ensures no loss of precision.
Using the fromFloat method
With the fromFloat
method, a new instance of type BigNumber
is created from a valid float value.
It is also possible to set a scale
for the object through this method.
Using the methods of mathematical operations
Addition
Performs an addition operation between this value and another value.
Subtraction
Performs a subtraction operation between this value and another value.
Multiplication
Performs a multiplication operation between this value and another value.
Division
Performs a division operation between this value and another value.
Using other resources
If you need to perform rounding, you can use the withRounding
method.
Use one of the following constants to specify the mode in which rounding occurs:
-
HALF_UP
: Round number away from zero when halfway. -
HALF_DOWN
: Round number to zero when halfway. -
HALF_EVEN
: Round number to the nearest even value when halfway. HALF_ODD
: Round number to the nearest odd value when halfway.
Others
Check out other available resources by looking at the BigNumber interface.
License
Math is licensed under MIT.
Contributing
Please follow the contributing guidelines to contribute to the project.
All versions of math with dependencies
ext-bcmath Version *