bcmath PHP 扩展的便利包装。

0.1.4 2018-01-23 23:43 UTC

README

bcmath PHP 扩展的便利包装。

安装

要安装 BCMath,运行

$ composer require edwardbrosens/bcmath

需求

BCMath 至少支持 PHP 5.6 和 HHVM。

快速开始

require __DIR__ . '/vendor/autoload.php';

use \BCMath\BCMath;

// Add two arbitrary precision numbers
$a = BCMath::add(1, 2); // ($a = 3)
$b = BCMath::sub(2, 1); // ($b = 1)

可用方法

BCMath::add($left_operand, $right_operand, $scale = null); // Add two arbitrary precision numbers
BCMath::sub($left_operand, $right_operand, $scale = null); // Subtract two arbitrary precision numbers
BCMath::mul($left_operand, $right_operand, $scale = null); // Multiply two arbitrary precision numbers
BCMath::div($left_operand, $right_operand, $scale = null); // Divide two arbitrary precision numbers
BCMath::mod($left_operand, $modulus); // Get modulus of an arbitrary precision number
BCMath::pow($left_operand, $right_operand, $scale = null); // Raise an arbitrary precision number to another
BCMath::sqrt($operand, $scale = null); // Get the square root of an arbitrary precision number
BCMath::scale ($scale); // Set default scale parameter for all BCMath and bcmath functions
BCMath::comp($left_operand, $right_operand, $scale = null); // Compare two arbitrary precision numbers
BCMath::powmod($left_operand, $right_operand, $modulus, $scale = null); // Raise an arbitrary precision number to another, reduced by a specified modulus

运行测试

要运行测试

$ git clone https://github.com/edwardbrosens/BCMath.git
$ composer install
$ ./vendor/bin/phpunit

贡献

  1. 在 GitHub 上 fork 仓库以进行更改。
  2. 为你要实现的新功能编写一个或多个测试,或为发现的错误编写修复程序。
  3. 发送拉取请求以合并你的分支。