021 / numeric
一个用于处理精确数字的PHP库。
v1.0.0
2024-04-08 09:25 UTC
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-09-08 10:22:50 UTC
README
一个方便处理任意精度数字的PHP库。
要求
- PHP 8.1 或更高版本
库基于 Brick\Math 包
尽管库可以在任何PHP安装上无缝工作,但仍强烈建议您安装 GMP 或 BCMath 扩展以提高计算速度。将在运行时自动选择可用的最快计算器实现。
安装
您可以通过composer安装此包
composer require 021/numeric
用法
use function O21\Numeric\Helpers\num; $number = num('123.456'); echo $number->add('0.544')->get();
计算
所有计算函数接受以下类型之一的值作为参数: string
、float
、int
、\O21\Numeric\Numeric
、\Brick\Math\BigNumber
。
比较
所有比较函数接受以下类型之一的值作为参数: string
、float
、int
、\O21\Numeric\Numeric
、\Brick\Math\BigNumber
。
格式化
辅助工具
命名空间: O21\Numeric\Helpers