philipbrown / math
该包已被 废弃 且不再维护。未建议替代包。
BC Math 的简单包装器
v2.0.1
2014-10-04 14:18 UTC
Requires
- php: >=5.4
- beberlei/assert: ~2.0
Requires (Dev)
- phpunit/phpunit: 4.0
This package is not auto-updated.
Last update: 2024-01-01 12:35:26 UTC
README
BC Math 的简单包装器
安装
将 philipbrown/math
添加到 composer.json
的需求中
{ "require": { "philipbrown/math": "~2.0" } }
使用 composer update
更新您的包。
使用方法
use PhilipBrown\Math\Math; /** * Add * * @param mixed $left * @param mixed $right * @param mixed $scale * @return PhilipBrown\Math\Number */ $number = Math::add(1.04, 2.406, 4); /** * Compare * * @param mixed $left * @param mixed $right * @param mixed $scale * @return PhilipBrown\Math\Number */ $number = Math::compare(2.4567, 2.4566, 4); /** * Divide * * @param mixed $left * @param mixed $right * @param mixed $scale * @return PhilipBrown\Math\Number */ $number = Math::divide(23.3945, 5, 4); /** * Modulus * * @param mixed $operand * @param mixed $modulus * @return PhilipBrown\Math\Number */ $number = Math::modulus(10, 3); /** * Multiply * * @param mixed $left * @param mixed $right * @param mixed $scale * @return PhilipBrown\Math\Number */ $number = Math::multiply(5.34, 2.2, 3); /** * Power * * @param mixed $left * @param mixed $right * @param mixed $scale * @return PhilipBrown\Math\Number */ $number = Math::power(43.22, 2, 5); /** * Square Root * * @param mixed $operand * @param mixed $scale * @return PhilipBrown\Math\Number */ $number = Math::squareRoot(454.213, 4); /** * Subtract * * @param mixed $left * @param mixed $right * @param mixed $scale * @return PhilipBrown\Math\Number */ $number = Math::subtract(10.888, 2.123, 3);