Convenience wrapper for the php bcmath extension.

0.1.4 2018-01-23 23:43 UTC

README

Convenience wrapper for the php bcmath extension.

Installation

To install BCMath, run:

$ composer require edwardbrosens/bcmath

Requirements

BCMath works with at least PHP 5.6 and HHVM.

Quick Start

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)

Available Methods

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

Run Tests

To run tests:

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

Contribute

  1. Fork the repository on GitHub in order to make changes.
  2. Write one or more tests for the new feature you're implementing or a fix for the bug you found.
  3. Send a pull request to get your branch merged.