Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 8, 2024 via composer

brick/math 0.11.0

Arbitrary-precision arithmetic library
Package summary
Share
0
issues
1
license
1
MIT
Package created
31 Aug 2014
Version published
15 Jan 2023
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
brick/math@0.11.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of brick/math 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does brick/math do?

The Brick\Math Composer package is an incredibly versatile PHP library used to manage arbitrary precision numbers. With heavy-duty calculation power and extensive support for several data types, it's an essential tool especially beneficial in handling large number computations, where standard PHP integers may overflow. The Brick\Math library tools deliver strict precision without any information loss.

How do you use brick/math?

To use Brick\Math in PHP, you need to start by installing it through Composer, a tool for dependency management in PHP. The command for installing Brick/Math via composer is: composer require brick/math.

Once installed, you can create instances of BigInteger, BigDecimal, and BigRational using the of() factory method. Here's an example of how you can use it:

use Brick\Math\BigInteger;

$integer = BigInteger::of(123);

$squared = $integer->multipliedBy($integer);  // Squaring the number.

echo $squared; // 15129

From the above code snippet, we are importing the BigInteger class and then creating an instance from the value of 123. We then perform arithmetic operations on this object to square the number.

Classes from Brick\Math library are immutable, meaning, whenever operations like plus(), minus(), or multipliedBy() are performed, they always return a new instance and leave the original BigInteger, BigDecimal, or BigRational object unaffected.

The library also supports chaining method calls for better readability. Here's an example of how to achieve this:

use Brick\Math\BigInteger;

$integer = BigInteger::of(10);

echo $integer->plus(5)->multipliedBy(3); // Outputs: 45

This above snippet adds 5 to the number and then multiplies the result by 3.

Where are the brick/math docs?

As for the Brick\Math package documentation, you can refer to the README provided on GitHub at https://github.com/brick/math. It covers everything from installation to usage with detailed examples, including arithmetic operations, rounding methods, bitwise operations, and serialization techniques. In addition, the repository also provides direct links to the classes for BigInteger, BigDecimal, BigRational, and RoundingMode, as well as clearly defined exception classes that fall under the Brick\Math\Exception namespace.