Skip to content
A simple wrapper for BC Math
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.gitignore
.scrutinizer.yml
.travis.yml
LICENSE
README.md
composer.json
phpunit.xml

README.md

Math

A simple wrapper for BC Math

Build Status Code Coverage Scrutinizer Code Quality

Installation

Add philipbrown/math as a requirement to composer.json:

{
  "require": {
    "philipbrown/math": "~2.0"
  }
}

Update your packages with composer update.

Usage

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);
You can’t perform that action at this time.