2017 © Pedro PelĆ”ez
 

library math

PHP library for arbitrary precision mathematics

image

maba/math

PHP library for arbitrary precision mathematics

  • Monday, July 27, 2015
  • by mariusbalcytis
  • Repository
  • 1 Watchers
  • 3 Stars
  • 1,378 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 20 % Grown

The README.md

PHP Math library

PHP library for arbitrary precision mathematics., (*1)

Installation

composer require maba/math

Why

var_dump(intval(9223372036854775807 + 1));
// int(-9223372036854775808)

var_dump(5.2 * 3 === 15.6);
// bool(false)

var_dump((8 + 92233720368547750) * 1500 / 1500 - 92233720368547750);
// float(16)

Usage

use Maba\Component\Math\BcMath;
use Maba\Component\Math\Math;
use Maba\Component\Math\NumberFormatter;

$basicMathImplementation = new BcMath();
$math = new Math($basicMathImplementation);

var_dump($math->add('9223372036854775807', '1'));
// string(40) "9223372036854775808.00000000000000000000"
var_dump($math->isEqual($math->mul('5.2', '3'), '15.6'));
// bool(true)
var_dump($math->sub($math->div($math->mul($math->add('8', '92233720368547750'), '1500'), '1500'), '92233720368547750'));
// string(22) "8.00000000000000000000"

$result = $math->pow($math->mul('3.141592653589793', '2.71828182845904523536'), 13);

$formatter = new NumberFormatter($math);
echo $formatter->formatNumber($result, 4, '.', ' '); // prints 1 284 625 710 591.2256

BcMath class uses bcmath functions. If you need to use some other arbitrary precision math implementation, implement BasicMathInterface., (*2)

Running tests

Travis status Coverage Status, (*3)

composer install
vendor/bin/phpunit

The Versions

27/07 2015

dev-master

9999999-dev

PHP library for arbitrary precision mathematics

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

by Marius Balčytis

math mathematics bcmath

20/09 2014

v1.0.1

1.0.1.0

PHP library for arbitrary precision mathematics

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

by Marius Balčytis

math mathematics bcmath

20/09 2014

v1.0.0

1.0.0.0

PHP library for arbitrary precision mathematics

  Sources   Download

MIT

The Requires

  • php >=5.3.2
  • ext-bcmath *

 

The Development Requires

by Marius Balčytis

math mathematics bcmath