Arbitrary-precision arithmetic library for PHP

Overview

Brick\Math

A PHP library to work with arbitrary precision numbers.

Build Status Coverage Status Latest Stable Version Total Downloads License

Installation

This library is installable via Composer:

composer require brick/math

Requirements

This library requires PHP 7.1 or later.

For PHP 5.6 and PHP 7.0 compatibility, you can use version 0.5. Note that these PHP versions are EOL and not supported anymore. If you're still using one of these PHP versions, you should consider upgrading as soon as possible.

Although the library can work seamlessly on any PHP installation, it is highly recommended that you install the GMP or BCMath extension to speed up calculations. The fastest available calculator implementation will be automatically selected at runtime.

Project status & release process

While this library is still under development, it is well tested and considered stable enough to use in production environments.

The current releases are numbered 0.x.y. When a non-breaking change is introduced (adding new methods, optimizing existing code, etc.), y is incremented.

When a breaking change is introduced, a new 0.x version cycle is always started.

It is therefore safe to lock your project to a given release cycle, such as ^0.9.

If you need to upgrade to a newer release cycle, check the release history for a list of changes introduced by each further 0.x.0 version.

Package contents

This library provides the following public classes in the Brick\Math namespace:

  • BigNumber: base class for BigInteger, BigDecimal and BigRational
  • BigInteger: represents an arbitrary-precision integer number.
  • BigDecimal: represents an arbitrary-precision decimal number.
  • BigRational: represents an arbitrary-precision rational number (fraction).
  • RoundingMode: holds constants for the rounding modes.

And the following exceptions in the Brick\Math\Exception namespace:

Overview

Instantiation

The constructors of the classes are not public, you must use a factory method to obtain an instance.

All classes provide an of() factory method that accepts any of the following types:

  • BigNumber instances
  • int numbers
  • float numbers
  • string representations of integer, decimal and rational numbers

Example:

BigInteger::of(123546);
BigInteger::of('9999999999999999999999999999999999999999999');

BigDecimal::of(1.2);
BigDecimal::of('9.99999999999999999999999999999999999999999999');

BigRational::of('2/3');
BigRational::of('1.1'); // 11/10

Note that all of() methods accept all of the representations above, as long as it can be safely converted to the current type:

BigInteger::of('1.00'); // 1
BigInteger::of('1.01'); // RoundingNecessaryException

BigDecimal::of('1/8'); // 0.125
BigDecimal::of('1/3'); // RoundingNecessaryException

Note about native integers: instantiating from an int is safe as long as you don't exceed the maximum value for your platform (PHP_INT_MAX), in which case it would be transparently converted to float by PHP without notice, and could result in a loss of information. In doubt, prefer instantiating from a string, which supports an unlimited numbers of digits:

echo BigInteger::of(999999999999999999999); // 1000000000000000000000
echo BigInteger::of('999999999999999999999'); // 999999999999999999999

Note about floating-point values: instantiating from a float might be unsafe, as floating-point values are imprecise by design, and could result in a loss of information. Always prefer instantiating from a string, which supports an unlimited number of digits:

echo BigDecimal::of(1.99999999999999999999); // 2
echo BigDecimal::of('1.99999999999999999999'); // 1.99999999999999999999

Immutability & chaining

The BigInteger, BigDecimal and BigRational classes are immutable: their value never changes, so that they can be safely passed around. All methods that return a BigInteger, BigDecimal or BigRational return a new object, leaving the original object unaffected:

$ten = BigInteger::of(10);

echo $ten->plus(5); // 15
echo $ten->multipliedBy(3); // 30

The methods can be chained for better readability:

echo BigInteger::of(10)->plus(5)->multipliedBy(3); // 45

Parameter types

All methods that accept a number: plus(), minus(), multipliedBy(), etc. accept the same types as of(). For example, given the following number:

$integer = BigInteger::of(123);

The following lines are equivalent:

$integer->multipliedBy(123);
$integer->multipliedBy('123');
$integer->multipliedBy($integer);

Just like of(), other types of BigNumber are acceptable, as long as they can be safely converted to the current type:

echo BigInteger::of(2)->multipliedBy(BigDecimal::of('2.0')); // 4
echo BigInteger::of(2)->multipliedBy(BigDecimal::of('2.5')); // RoundingNecessaryException
echo BigDecimal::of(2.5)->multipliedBy(BigInteger::of(2)); // 5.0

Division & rounding

BigInteger

By default, dividing a BigInteger returns the exact result of the division, or throws an exception if the remainder of the division is not zero:

echo BigInteger::of(999)->dividedBy(3); // 333
echo BigInteger::of(1000)->dividedBy(3); // RoundingNecessaryException

You can pass an optional rounding mode to round the result, if necessary:

echo BigInteger::of(1000)->dividedBy(3, RoundingMode::DOWN); // 333
echo BigInteger::of(1000)->dividedBy(3, RoundingMode::UP); // 334

If you're into quotients and remainders, there are methods for this, too:

echo BigInteger::of(1000)->quotient(3); // 333
echo BigInteger::of(1000)->remainder(3); // 1

You can even get both at the same time:

[$quotient, $remainder] = BigInteger::of(1000)->quotientAndRemainder(3);
BigDecimal

Dividing a BigDecimal always requires a scale to be specified. If the exact result of the division does not fit in the given scale, a rounding mode must be provided.

echo BigDecimal::of(1)->dividedBy('8', 3); // 0.125
echo BigDecimal::of(1)->dividedBy('8', 2); // RoundingNecessaryException
echo BigDecimal::of(1)->dividedBy('8', 2, RoundingMode::HALF_DOWN); // 0.12
echo BigDecimal::of(1)->dividedBy('8', 2, RoundingMode::HALF_UP); // 0.13

If you know that the division yields a finite number of decimals places, you can use exactlyDividedBy(), which will automatically compute the required scale to fit the result, or throw an exception if the division yields an infinite repeating decimal:

echo BigDecimal::of(1)->exactlyDividedBy(256); // 0.00390625
echo BigDecimal::of(1)->exactlyDividedBy(11); // RoundingNecessaryException
BigRational

The result of the division of a BigRational can always be represented exactly:

echo BigRational::of('123/456')->dividedBy('7'); // 123/3192
echo BigRational::of('123/456')->dividedBy('9/8'); // 984/4104

Bitwise operations

BigInteger supports bitwise operations:

  • and()
  • or()
  • xor()
  • not()

and bit shifting:

  • shiftedLeft()
  • shiftedRight()

Serialization

BigInteger, BigDecimal and BigRational can be safely serialized on a machine and unserialized on another, even if these machines do not share the same set of PHP extensions.

For example, serializing on a machine with GMP support and unserializing on a machine that does not have this extension installed will still work as expected.

brick/math for enterprise

Available as part of the Tidelift Subscription.

The maintainers of brick/math and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Comments
  • Add bitwise operations to BigInteger

    Add bitwise operations to BigInteger

    I'm currently working on a CBOR parser and ran into a problem when parsing big integers, so I needed a proper BigInteger implementation. This project seems really well written and supported, so I chose to use it. Sadly, in order to use it, I needed bitwise operations on the integers.

    This PR adds the following methods to BigInteger:

    • or($that)
    • and($that)
    • xor($that)
    • shiftLeft(int $distance)
    • shiftRight(int $distance)

    In order to not pollute the BigInteger with implementation details about bitwise operations, all but the shifting is encapsulated in the Bitwise class in the internal namespace. As this is an implementation detail, that class is blackbox-tested through the BigIntegerTest.

    I've tried to follow the existing coding standard as well as I understood it and documented everything like the existing methods.

    It would be great if (in case everything is alright) you could merge and tag this addition!

    opened by DASPRiD 27
  • Bitwise NOT

    Bitwise NOT

    Hi there, first of all, thanks for this great library!

    This library has support for bitwise operations and, or and xor, but I found myself needing not. What would be the suggested way of achieving it? Java's BigInteger has a not method. Are we able to have not functionality using any of the existing methods or it would require implementing it?

    I know we could do xor with all-1s, or invert the digits of the binary string.

    Please advise, thanks!

    opened by luiz-brandao 21
  • Psalm support (+general PHPDoc fixes)

    Psalm support (+general PHPDoc fixes)

    • [x] Psalm config
    • [x] Psalm baseline file (if there are still errors after my quick fixes)
    • [x] number β†’ int|float (PHPDoc standard doesn't contain such a type)
    • [x] Psalm's @param-out
    • [ ] @psalm-immutable (for classes) and @psalm-pure (for static factory methods) β€” probably in a separate PR
    opened by alexeyshockov 13
  • Adding support for environments that have a system locales with different decimal separator

    Adding support for environments that have a system locales with different decimal separator

    |Q|A| | - | - | |Branch?|master| |Bug fix?|yes| |New feature?|no| |BC breaks?|no| |Tests pass?|yes|

    STR:

    1. environment must have locale with decimal separator different from . (for example de_DE.UTF-8) or locale set by terminal variable like export LC_ALL=de_DE.UTF-8
    2. run any code which do calculations with float values and try to convert value to brick/math type

    For example:

    $decimal = \Brick\Math\BigDecimal::of(5/2);
    

    It will not give an error if locale is equal to eu_US. But if locale is equal to de_DE then there will be an error Brick\Math\Exception\NumberFormatException : The given value "2,5" does not represent a valid number.. It happened because in this environment PHP will use , as decimal separator and ::of() method must be sensitive to it.

    It can also happen when using Doctrine and convert float values from DB to brick/math type.

    opened by manowark 9
  • brick/math method for gmp_invert

    brick/math method for gmp_invert

    Hi,

    During the implementation of this library in one of my projects, I spent a few moment to find a way to use the GMP method gmp_invert. In the end, I created my own method, by it could be directly implemented here: the gmp engine will directly use the gmp_invert method. Other engines can use the following.

    Hope it helps.

    <?php
    
    declare(strict_types=1);
    
    require_once 'vendor/autoload.php';
    
    use Brick\Math\BigInteger;
    use Brick\Math\RoundingMode;
    
    function modInverse(BigInteger $a, BigInteger $b): BigInteger
    {
        $x = BigInteger::zero();
        $y = BigInteger::zero();
        $g = gcdExtended($a, $b, $x, $y);
        if (!$g->isEqualTo(BigInteger::one())) {
            throw new InvalidArgumentException('Unable to compute the modInverse for the given modulus');
        }
    
        return $x->mod($b)->plus($b)->mod($b);
    }
    
    function gcdExtended(BigInteger $a, BigInteger $b, BigInteger &$x, BigInteger &$y): BigInteger
    {
        if ($a->isEqualTo(BigInteger::zero())) {
            $x = BigInteger::zero();
            $y = BigInteger::one();
    
            return $b;
        }
    
        $x1 = BigInteger::zero();
        $y1 = BigInteger::zero();
        $gcd = gcdExtended($b->mod($a), $a, $x1, $y1);
    
        $x = $y1->minus($b->dividedBy($a, RoundingMode::FLOOR)->multipliedBy($x1));
        $y = $x1;
    
        return $gcd;
    }
    

    Example:

    gmp_invert(5, 11); //GMP resource of value 9
    
    $five = BigInteger::of(5);
    $eleven = BigInteger::of(11);
    modInverse($five, $eleven); // BigInteger of value 9
    
    opened by Spomky 8
  • Add support for custom object serialization

    Add support for custom object serialization

    This adds support for the custom object serialization feature added in PHP 7.4. This is needed to suppress deprecation warnings in PHP 8.1 since the Serializable interface is now deprecated.

    opened by TRowbotham 7
  • `gmp_export` equivalent

    `gmp_export` equivalent

    Hi,

    I am not sure if there is an equivalent method for gmp_export. In my case, I have a GMP object that I need to export using the following parameters:

    $bin = gmp_export($value, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
    

    Any idea?

    opened by Spomky 6
  • Fix padding of negative byte numbers in bitwise operation

    Fix padding of negative byte numbers in bitwise operation

    Call me stupid: When padding the binaryX and Y values, I didn't pad with the individual sign byte but always with a positive sign byte. All new tests pass now.

    opened by DASPRiD 6
  • Call simplify before toFloat conversion

    Call simplify before toFloat conversion

    Calling $rationalNumber->toFloat() may result in a huge loss of precision due to the limits of floating point representation which can be prevented (not every time, but in a lot of real-world cases) by calling ->simplified() first.

    ~~Such loss of precision caused by a very large nominator or denominator may be actually (and unexpectedly) way larger than if regular 64bit floating numbers were used for all math operations instead (assuming some real-world numeric range).~~ Even with regular numeric range, float overflow may easily occur.

    We ran into this issue in production quite a few times in the legacy parts where we did not migrate yet to using BigRational and we perform the float conversion.

    Therefore I'd like to suggest calling ->simplify every time before ->toFloat() conversion. I understand that the operation does not come for free, I'd like to hear your opinion :)

    Thank you for this otherwise excellent library!

    opened by olsavmic 5
  • New Psalm issues

    New Psalm issues

    The latest build highlighted yet another kind of Psalm issue:

    ERROR: MoreSpecificReturnType - src/BigNumber.php:159:16 - The declared return type 'Brick\Math\BigNumber&static' for Brick\Math\BigNumber::min is more specific than the inferred return type 'Brick\Math\BigNumber' (see https://psalm.dev/070) * @ return static The minimum value. ERROR: LessSpecificReturnStatement - src/BigNumber.php:182:16 - The type 'Brick\Math\BigNumber' is more general than the declared return type 'Brick\Math\BigNumber&static' for Brick\Math\BigNumber::min (see https://psalm.dev/129) return $min; ...

    https://travis-ci.org/github/brick/math/jobs/675371330

    @alexeyshockov Could you please have a look?

    opened by BenMorel 5
  • Fixed missing test cases and PHP version

    Fixed missing test cases and PHP version

    It looks like the tests were incorrectly casting some cases to a string which means the tests were not actually doing what they were meant to. I've fixed this also. NB This was highlighted because PHPUnit calls tests with strict types enabled from v8 upwards.

    It's good practice to bounded version constraints (such as on the PHP versions). I've also tweaked the minimum dependency versions so that they work properly on PHP 7.4.

    opened by GrahamCampbell 5
  • Output a BigRational in decimal form with period

    Output a BigRational in decimal form with period

    It could be nice to provide a way to output a BigRational as a decimal number with its decimal period.

    For example, 10/3 could be output as 3.(3), while 171/70 could be output as 2.4(428571). (Not sure about the correct format here, is there a standard for this?)

    opened by BenMorel 0
  • RFC: add `getPrecision` method.

    RFC: add `getPrecision` method.

    Hi,

    Similar to getScale, would you be on favor of adding a method getPrecision? I want to perform app side validation on BigDecimal before passing to Postgres numeric fields, and getPrecision would make that easier.

    Thanks!

    opened by bendavies 11
Releases(0.10.2)
  • 0.10.2(Aug 10, 2022)

  • 0.10.1(Aug 1, 2022)

  • 0.10.0(Jun 18, 2022)

  • 0.9.3(Aug 15, 2021)

    πŸš€ Compatibility with PHP 8.1

    • Support for custom object serialization; this removes a warning on PHP 8.1 due to the Serializable interface being deprecated (#60) thanks @TRowbotham
    Source code(tar.gz)
    Source code(zip)
  • 0.9.2(Jan 20, 2021)

    :bug: Bug fix

    • Incorrect results could be returned when using the BCMath calculator, with a default scale set with bcscale(), on PHP >= 7.2 (#55).
    Source code(tar.gz)
    Source code(zip)
  • 0.9.1(Aug 19, 2020)

    ✨ New features

    • BigInteger::not() returns the bitwise NOT value

    πŸ› Bug fixes

    • BigInteger::toBytes() could return an incorrect binary representation for some numbers
    • The bitwise operations and(), or(), xor() on BigInteger could return an incorrect result when the GMP extension is not available
    Source code(tar.gz)
    Source code(zip)
  • 0.9.0(Aug 18, 2020)

    πŸ‘Œ Improvements

    • BigNumber::of() now accepts .123 and 123. formats, both of which return a BigDecimal

    πŸ’₯ Breaking changes

    • Deprecated method BigInteger::powerMod() has been removed - use modPow() instead
    • Deprecated method BigInteger::parse() has been removed - use fromBase() instead
    Source code(tar.gz)
    Source code(zip)
  • 0.8.17(Aug 19, 2020)

    πŸ› Bug fix

    • BigInteger::toBytes() could return an incorrect binary representation for some numbers
    • The bitwise operations and(), or(), xor() on BigInteger could return an incorrect result when the GMP extension is not available
    Source code(tar.gz)
    Source code(zip)
  • 0.8.16(Aug 18, 2020)

    πŸš‘ Critical fix

    • This version reintroduces the deprecated BigInteger::parse() method, that has been removed by mistake in version 0.8.9 and should have lasted for the whole 0.8 release cycle.

    ✨ New features

    • BigInteger::modInverse() calculates a modular multiplicative inverse
    • BigInteger::fromBytes() creates a BigInteger from a byte string
    • BigInteger::toBytes() converts a BigInteger to a byte string
    • BigInteger::randomBits() creates a pseudo-random BigInteger of a given bit length
    • BigInteger::randomRange() creates a pseudo-random BigInteger between two bounds

    πŸ’© Deprecations

    • BigInteger::powerMod() is now deprecated in favour of modPow()
    Source code(tar.gz)
    Source code(zip)
  • 0.8.15(Apr 15, 2020)

    πŸ› Fixes

    • added missing ext-json requirement, due to BigNumber implementing JsonSerializable

    ⚑️ Optimizations

    • additional optimization in BigInteger::remainder()
    Source code(tar.gz)
    Source code(zip)
  • 0.8.14(Feb 18, 2020)

  • 0.8.13(Feb 16, 2020)

    ✨ New features

    • BigInteger::isEven() tests whether the number is even
    • BigInteger::isOdd() tests whether the number is odd
    • BigInteger::testBit() tests if a bit is set
    • BigInteger::getBitLength() returns the number of bits in the minimal representation of the number
    Source code(tar.gz)
    Source code(zip)
  • 0.8.12(Feb 3, 2020)

    πŸ› οΈ Maintenance release

    Classes are now annotated for better static analysis with psalm.

    This is a maintenance release: no bug fixes, no new features, no breaking changes.

    Source code(tar.gz)
    Source code(zip)
  • 0.8.11(Jan 23, 2020)

  • 0.8.10(Jan 21, 2020)

    ✨ New feature

    BigInteger::mod() returns the modulo of two numbers. The modulo differs from the remainder when the signs of the operands are different.

    Source code(tar.gz)
    Source code(zip)
  • 0.8.9(Jan 8, 2020)

    ⚑️ Performance improvements

    A few additional optimizations in BigInteger and BigDecimal when one of the operands can be returned as is. Thanks to @tomtomsen in #24.

    Source code(tar.gz)
    Source code(zip)
  • 0.8.8(Apr 25, 2019)

    πŸ› Bug fixes

    • BigInteger::toBase() could return an empty string for zero values (BCMath & Native calculators only, GMP calculator unaffected)

    ✨ New features

    • BigInteger::toArbitraryBase() converts a number to an arbitrary base, using a custom alphabet
    • BigInteger::fromArbitraryBase() converts a string in an arbitrary base, using a custom alphabet, back to a number

    These methods can be used as the foundation to convert strings between different bases/alphabets, using BigInteger as an intermediate representation.

    πŸ’© Deprecations

    • BigInteger::parse() is now deprecated in favour of fromBase()

    BigInteger::fromBase() works the same way as parse(), with 2 minor differences:

    • the $base parameter is required, it does not default to 10
    • it throws a NumberFormatException instead of an InvalidArgumentException when the number is malformed
    Source code(tar.gz)
    Source code(zip)
  • 0.8.7(Apr 20, 2019)

    Improvements

    • Safer conversion from float when using custom locales
    • Much faster NativeCalculator implementation πŸš€

    You can expect at least a 3x performance improvement for common arithmetic operations when using the library on systems without GMP or BCMath; it gets exponentially faster on multiplications with a high number of digits. This is due to calculations now being performed on whole blocks of digits (the block size depending on the platform, 32-bit or 64-bit) instead of digit-by-digit as before.

    Source code(tar.gz)
    Source code(zip)
  • 0.8.6(Apr 11, 2019)

  • 0.8.5(Feb 12, 2019)

    Bug fix: of() factory methods could fail when passing a float in environments using a LC_NUMERIC locale with a decimal separator other than '.' (#20).

    Thanks @manowark πŸ‘

    Source code(tar.gz)
    Source code(zip)
  • 0.8.4(Dec 7, 2018)

  • 0.8.3(Dec 6, 2018)

    New method

    BigInteger::sqrt() calculates the square root of a number (thanks @peter279k).

    New exception

    NegativeNumberException is thrown when calling sqrt() on a negative number.

    Source code(tar.gz)
    Source code(zip)
  • 0.8.2(Nov 8, 2018)

  • 0.8.1(Nov 7, 2018)

  • 0.8.0(Oct 13, 2018)

    Breaking changes

    The following deprecated methods have been removed. Use the new method name instead:

    | Method removed | Replacement method | | --- | --- | | BigDecimal::getIntegral() | BigDecimal::getIntegralPart() | | BigDecimal::getFraction() | BigDecimal::getFractionalPart() |


    New features

    BigInteger has been augmented with 5 new methods for bitwise operations:

    | New method | Description | | --- | --- | | and() | performs a bitwise AND operation on two numbers | | or() | performs a bitwise OR operation on two numbers | | xor() | performs a bitwise XOR operation on two numbers | | shiftedLeft() | returns the number shifted left by a number of bits | | shiftedRight() | returns the number shifted right by a number of bits |

    Thanks to @DASPRiD πŸ‘

    Source code(tar.gz)
    Source code(zip)
  • 0.7.3(Aug 20, 2018)

    New method: BigDecimal::hasNonZeroFractionalPart()

    Renamed/deprecated methods:

    • BigDecimal::getIntegral() has been renamed to getIntegralPart() and is now deprecated
    • BigDecimal::getFraction() has been renamed to getFractionalPart() and is now deprecated
    Source code(tar.gz)
    Source code(zip)
  • 0.7.2(Jul 21, 2018)

  • 0.7.1(Mar 1, 2018)

    This is a maintenance release, no code has been changed.

    • When installed with --no-dev, the autoloader does not autoload tests anymore
    • Tests and other files unnecessary for production are excluded from the dist package

    This will help make installations more compact.

    Source code(tar.gz)
    Source code(zip)
  • 0.7.0(Oct 2, 2017)

    Methods renamed:

    • BigNumber:sign() has been renamed to getSign()
    • BigDecimal::unscaledValue() has been renamed to getUnscaledValue()
    • BigDecimal::scale() has been renamed to getScale()
    • BigDecimal::integral() has been renamed to getIntegral()
    • BigDecimal::fraction() has been renamed to getFraction()
    • BigRational::numerator() has been renamed to getNumerator()
    • BigRational::denominator() has been renamed to getDenominator()

    Classes renamed:

    • ArithmeticException has been renamed to MathException
    Source code(tar.gz)
    Source code(zip)
  • 0.6.2(Oct 2, 2017)

Owner
Brick
Building blocks for professional PHP applications
Brick
PHP version of Google's phone number handling library

libphonenumber for PHP What is it? A PHP library for parsing, formatting, storing and validating international phone numbers. This library is based on

Joshua Gigg 4.2k Jan 7, 2023
A PHP 5.3+ mathematics library, providing functionality for large numbers

Moontoast Math Library Moontoast\Math is useful for working with integers that are larger than (or may become larger than, through mathematical comput

Moontoast 245 Sep 8, 2022
Advanced Mathematics Library for PHP (port of Numbers.js)

Numbers.php Numbers.php - an advanced mathematics toolkit for PHP >= 5.3. It is a port of Numbers.js - same toolkit for JavaScript. There is a version

null 159 Jul 24, 2022
Library for converting units and sizes in PHP

php-conversion Library for converting units and sizes in PHP. Units supported Acceleration Angle Area Digital information Electric current Frequency F

Christoffer Niska 127 Dec 23, 2022
BigNum library for PHP compatible with bn.js

BigNum library for PHP Information This library provides a PHP Big Number API compatible with bn.js and is used in Fast PHP ECC library elliptic-php.

Simplito 16 Nov 13, 2022
Library for converting units and sizes in PHP

php-conversion Library for converting units and sizes in PHP. Units supported Acceleration Angle Area Digital information Electric current Frequency F

Christoffer Niska 122 Mar 16, 2021
Mark Rogoyski 2.2k Dec 29, 2022
Tensor is a library and extension that provides objects for scientific computing in PHP.

Tensor is a library and extension that provides objects for scientific computing in PHP. The multithreaded extension is especially suited for computing large sets of numbers. In some cases, the extension is 230X faster than the same operation in PHPland. Tensor is used by libraries such as Rubix ML to build and accelerate machine learning algorithms such as linear regression, dimensionality reduction, and neural networks.

Rubix 157 Jan 3, 2023
Library to parse, format and convert byte units

Byte Units This is a utility component for parsing, formatting, converting and manipulating byte units in various formats. Usage <?php // Bytes manip

Gabriele Lana 156 Dec 9, 2022
A library for handling physical quantities and the units of measure in which they're represented.

PHP Units of Measure master: Introduction This is a PHP library for representing and converting physical units of measure. The utility of this library

Jonathan Hanson 21 Sep 28, 2022
Unit converter and calculator for php

Unit converter and calculator This library uses the awesome lisachenko/z-engine to allow mathematical operations on objects, allowing to do stuff like

Dominik ChrΓ‘steckΓ½ 8 Apr 8, 2022
Arithmetic expression solver PHP library

arithmexp An arithmetic expression solver Usage $operators = OperatorRegistry::default(); $expression = new ArithmeticExpression($operators, "4 - 3 +

Muqsit Rayyan 17 Nov 13, 2022
Sey is a powerful math interpreter with infinite-precision.

Sey, pronounce say, is a powerful math interpreter with infinite-precision.

FΓ©lix Dorn 13 Oct 1, 2022
Extract and evolution of the magento2-currency-precision module from the magento2-jp project from @Magento

Currency Precision Module for Magento 2 This module aims to help merchants to manage easily their currency precision in Magento 2. DISCLAIMER Initiall

OpenGento 3 Dec 17, 2021
The VarDumper component provides mechanisms for walking through any arbitrary PHP variable. It provides a better dump() function that you can use instead of var_dump().

VarDumper Component The VarDumper component provides mechanisms for walking through any arbitrary PHP variable. It provides a better dump() function t

Symfony 7.1k Dec 23, 2022
The VarDumper component provides mechanisms for walking through any arbitrary PHP variable. It provides a better dump() function that you can use instead of var_dump().

VarDumper Component The VarDumper component provides mechanisms for walking through any arbitrary PHP variable. It provides a better dump() function t

Symfony 7.1k Jan 1, 2023
A filesystem-like repository for storing arbitrary resources.

The Puli Repository Component Latest release: 1.0.0-beta10 PHP >= 5.3.9 The Puli Repository Component provides an API for storing arbitrary resources

Puli 435 Nov 20, 2022
Arbitrary number base converter.

Numbase Easily convert numbers between arbitrary bases and symbol sets. Installation This library is available on Packagist as thunderer/numbase. It r

Tomasz Kowalczyk 23 Sep 25, 2022
Okex API Like the official document interface, Support for arbitrary extension.

It is recommended that you read the official document first Okex docs https://www.okex.com/docs/en Okex Simulation Test API https://www.okex.com/docs/

lin 34 Jan 1, 2023
Exploit the vulnerability to install arbitrary applications in k61v1 without ROOT

k61v1injector Arbitrary application installer for Qin F21 Pro Exploit the vulnerability to install arbitrary applications in k61v1 without ROOT. Feel

Jim Wu 14 Nov 10, 2022