021 / numeric
A PHP library for working with precise numbers.
Requires
- php: ^8.1|^8.2|^8.3
- brick/math: ^0.11
Requires (Dev)
- laravel/pint: ^1.13
- phpunit/phpunit: ^9.5|^10.0
This package is auto-updated.
Last update: 2024-10-08 10:25:36 UTC
README
A PHP library to convenient work with arbitrary precision numbers.
Requirements
- PHP 8.1 or higher
Library is based on Brick\Math package:
Although the library can work seamlessly on any PHP installation, it is highly recommended that you install the GMP or BCMath extension to speed up calculations. The fastest available calculator implementation will be automatically selected at runtime.
Installation
You can install the package via composer:
composer require 021/numeric
Usage
use function O21\Numeric\Helpers\num; $number = num('123.456'); echo $number->add('0.544')->get();
Calculations
All computational functions accept as an argument a value of one of the following
types: string
, float
, int
, \O21\Numeric\Numeric
, \Brick\Math\BigNumber
.
Comparisons
All comparison functions accept as an argument a value of one of the following
types: string
, float
, int
, \O21\Numeric\Numeric
, \Brick\Math\BigNumber
.
Formatting
Helpers
Namespace: O21\Numeric\Helpers