Arbitrary-precision arithmetic library for PHP
MIT License
Bot releases are visible (Hide)
⚡️ Performance improvements
BigNumber::of()
is now faster, thanks to @SebastienDug in #77.Published by BenMorel 11 months ago
💥 Breaking changes
RoundingMode
is now an enum
; if you're type-hinting rounding modes, you need to type-hint against RoundingMode
instead of int
nowBigNumber
classes do not implement the Serializable
interface anymore (they use the new custom object serialization mechanism)BigNumber
subclasses:
BigNumber::of()
is now static
BigNumber
has a new abstract method from()
public
and protected
functions of BigNumber
are now final
Published by BenMorel almost 2 years ago
💥 Breaking changes
MathException
now extends Exception
instead of RuntimeException
* You may now run into type errors if you were passing Stringable
objects to of()
or any of the methods internally calling of()
, with strict_types
enabled. You can fix this by casting Stringable
objects to string
first.
Published by BenMorel about 2 years ago
👌 Improvements
BigRational::toFloat()
now simplifies the fraction before performing division (#73) thanks to @olsavmicPublished by BenMorel about 2 years ago
✨ New features
BigInteger::gcdMultiple()
returns the GCD of multiple BigInteger
numbersPublished by BenMorel over 2 years ago
💥 Breaking changes
Published by BenMorel about 3 years ago
🚀 Compatibility with PHP 8.1
Serializable
interface being deprecated (#60) thanks @TRowbothamPublished by BenMorel over 3 years ago
🐛 Bug fix
bcscale()
, on PHP >= 7.2 (#55).Published by BenMorel about 4 years ago
✨ New features
BigInteger::not()
returns the bitwise NOT
value🐛 Bug fixes
BigInteger::toBytes()
could return an incorrect binary representation for some numbersand()
, or()
, xor()
on BigInteger
could return an incorrect result when the GMP extension is not availablePublished by BenMorel about 4 years ago
🐛 Bug fix
BigInteger::toBytes()
could return an incorrect binary representation for some numbersand()
, or()
, xor()
on BigInteger
could return an incorrect result when the GMP extension is not availablePublished by BenMorel about 4 years ago
👌 Improvements
BigNumber::of()
now accepts .123
and 123.
formats, both of which return a BigDecimal
💥 Breaking changes
BigInteger::powerMod()
has been removed - use modPow()
insteadBigInteger::parse()
has been removed - use fromBase()
insteadPublished by BenMorel about 4 years ago
🚑 Critical fix
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 inverseBigInteger::fromBytes()
creates a BigInteger
from a byte stringBigInteger::toBytes()
converts a BigInteger
to a byte stringBigInteger::randomBits()
creates a pseudo-random BigInteger
of a given bit lengthBigInteger::randomRange()
creates a pseudo-random BigInteger
between two bounds💩 Deprecations
BigInteger::powerMod()
is now deprecated in favour of modPow()
Published by BenMorel over 4 years ago
🐛 Fixes
ext-json
requirement, due to BigNumber
implementing JsonSerializable
⚡️ Optimizations
BigInteger::remainder()
Published by BenMorel over 4 years ago
✨ New features
BigInteger::getLowestSetBit()
returns the index of the rightmost one bitPublished by BenMorel over 4 years ago
✨ New features
BigInteger::isEven()
tests whether the number is evenBigInteger::isOdd()
tests whether the number is oddBigInteger::testBit()
tests if a bit is setBigInteger::getBitLength()
returns the number of bits in the minimal representation of the numberPublished by BenMorel over 4 years ago
✨ New feature
BigInteger::powerMod()
performs a power-with-modulo operation. Useful for crypto.
Published by BenMorel over 4 years ago
✨ New feature
BigInteger::mod()
returns the modulo of two numbers. The modulo differs from the remainder when the signs of the operands are different.
Published by BenMorel almost 5 years ago
⚡️ 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.
Published by BenMorel over 5 years ago
🐛 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 alphabetBigInteger::fromArbitraryBase()
converts a string in an arbitrary base, using a custom alphabet, back to a numberThese 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:
$base
parameter is required, it does not default to 10
NumberFormatException
instead of an InvalidArgumentException
when the number is malformed