brick/math
Arbitrary-precision arithmetic library
0.19.1
578M downloads/mo
#40 most downloaded on composer
brick/math
What this package is like to depend on
Last release 15 days ago
08 Aug 2026
Release timing varies
gaps range from 8 days to 3 months
Nearly every release is documented
notes for 78 of 78 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
78 releases · first in 2014
19 releases in the last 12 months
see the full history below
Release timeline
78 releases · Aug 2014 to Aug 2026Releases
latest 60 of 78-
0.19.108 Aug 2026Release notes
Open source →✨ New features
- New exception class:
PlatformException(replacesUnsupportedPlatformException) PlatformExceptionis now thrown whenpreg_match()fails due to improper PHP configurationPlatformExceptionis now thrown whenPHP_INT_SIZEis an unsupported value
🗑️ Deprecations
- Exception class
UnsupportedPlatformExceptionis deprecated; catchPlatformExceptioninstead
Release notes
Open source →✨ New features
- New exception class:
PlatformException(replacesUnsupportedPlatformException) PlatformExceptionis now thrown whenpreg_match()fails due to improper PHP configurationPlatformExceptionis now thrown whenPHP_INT_SIZEis an unsupported value
🗑️ Deprecations
- Exception class
UnsupportedPlatformExceptionis deprecated; catchPlatformExceptioninstead
- New exception class:
-
0.19.030 Jul 2026Release notes
Open source →✨ New features
- New rounding mode:
RoundingMode::HalfOdd - New method:
RoundingMode::fromNativeRoundingMode()converts from a native PHPRoundingModeenum (PHP 8.4+)
Release notes
Open source →✨ New features
- New rounding mode:
RoundingMode::HalfOdd - New method:
RoundingMode::fromNativeRoundingMode()converts from a native PHPRoundingModeenum (PHP 8.4+)
- New rounding mode:
-
0.18.014 Jun 2026Release notes
Open source →💥 Breaking changes
The following breaking change only affects you if you're using named arguments:
BigInteger::fromBytes()now uses$bytesas the parameter name
🐛 Bug fixes
of()no longer accepts a trailing newline (\n) in the input string; such input now throwsNumberFormatExceptionof()now consistently throwsNumberFormatExceptionfor exponents too large to process, instead ofIntegerOverflowExceptionin some casesBigInteger::fromBase()now reports the invalid character with its original case in theNumberFormatExceptionmessage, instead of lower-casing it
⚡️ Performance improvements
BigInteger::gcd()no longer exhausts memory on large inputs when the GMP extension is not installedBigInteger::modInverse()no longer exhausts memory on large inputs, and is faster when the GMP extension is not installed
👌 Static analysis improvements
- Narrowed parameter and return types with static analysis annotations:
nthRoot()'s$nis nowpositive-intBigInteger::toBase(),toArbitraryBase(),toBytes()andBigRational::toRepeatingDecimalString()now returnnon-empty-string
Release notes
Open source →💥 Breaking changes
The following breaking change only affects you if you're using named arguments:
BigInteger::fromBytes()now uses$bytesas the parameter name
🐛 Bug fixes
of()no longer accepts a trailing newline (\n) in the input string; such input now throwsNumberFormatExceptionof()now consistently throwsNumberFormatExceptionfor exponents too large to process, instead ofIntegerOverflowExceptionin some casesBigInteger::fromBase()now reports the invalid character with its original case in theNumberFormatExceptionmessage, instead of lower-casing it
⚡️ Performance improvements
BigInteger::gcd()no longer exhausts memory on large inputs when the GMP extension is not installedBigInteger::modInverse()no longer exhausts memory on large inputs, and is faster when the GMP extension is not installed
👌 Static analysis improvements
- Narrowed parameter and return types with static analysis annotations:
nthRoot()'s$nis nowpositive-intBigInteger::toBase(),toArbitraryBase(),toBytes()andBigRational::toRepeatingDecimalString()now returnnon-empty-string
-
0.17.225 May 2026Release notes
Open source →✨ New features
- New methods:
BigInteger::nthRoot()andBigDecimal::nthRoot()compute the nth root of a number (#113 by @Pablo1Gustavo)
Release notes
Open source →✨ New features
- New methods:
BigInteger::nthRoot()andBigDecimal::nthRoot()compute the nth root of a number (#113 by @Pablo1Gustavo)
- New methods:
-
0.17.119 Apr 2026Release notes
Open source →👌 Improvements
- More precise
floatapproximations inBigRational::toFloat()
Release notes
Open source →👌 Improvements
- More precise
floatapproximations inBigRational::toFloat()
- More precise
-
0.17.017 Mar 2026Release notes
Open source →💥 Breaking changes
- Deprecated method
BigDecimal::hasNonZeroFractionalPart()has been removed, use! $number->getFractionalPart()->isZero()instead - Exception constructors and factory methods are now
@internal
✨ Compatibility improvements
BigDecimal::fromFloatExact()now supports 32-bit PHP
Release notes
Open source →💥 Breaking changes
- Deprecated method
BigDecimal::hasNonZeroFractionalPart()has been removed, use! $number->getFractionalPart()->isZero()instead - Exception constructors and factory methods are now
@internal
✨ Compatibility improvements
BigDecimal::fromFloatExact()now supports 32-bit PHP
- Deprecated method
-
0.16.215 Mar 2026Release notes
Open source →✨ New features
New methods to create a
BigDecimalfrom afloatvalue:BigDecimal::fromFloatExact()BigDecimal::fromFloatShortest()
Release notes
Open source →✨ New features
New methods to create a
BigDecimalfrom afloatvalue:BigDecimal::fromFloatExact()BigDecimal::fromFloatShortest()
-
0.16.109 Mar 2026Release notes
Open source →👌 Improvements
- Add
@return non-empty-stringtotoString(),jsonSerialize()and__toString()(#111 by @vudaltsov)
Release notes
Open source →👌 Improvements
- Add
@return non-empty-stringtotoString(),jsonSerialize()and__toString()(#111 by @vudaltsov)
- Add
-
0.16.006 Mar 2026Release notes
Open source →💥 Breaking changes
BigInteger::getLowestSetBit()now returnsnullinstead of-1when the number is zero- Deprecated method
BigRational::simplified()has been removed, as it is now a no-op
✨ New features
- New method:
BigDecimal::getIntegralPart()returns the integral part asBigInteger(this method existed with a different signature in version 0.14, and was removed in 0.15) - New method:
BigDecimal::getFractionalPart()returns the fractional part asBigDecimal(this method existed with a different signature and meaning in version 0.14, and was removed in 0.15)
🗑️ Deprecations
- Method
BigDecimal::hasNonZeroFractionalPart()is deprecated, use->getFractionalPart()->isZero()instead
Release notes
Open source →💥 Breaking changes
BigInteger::getLowestSetBit()now returnsnullinstead of-1when the number is zero- Deprecated method
BigRational::simplified()has been removed, as it is now a no-op
✨ New features
- New method:
BigDecimal::getIntegralPart()returns the integral part asBigInteger(this method existed with a different signature in version 0.14, and was removed in 0.15) - New method:
BigDecimal::getFractionalPart()returns the fractional part asBigDecimal(this method existed with a different signature and meaning in version 0.14, and was removed in 0.15)
🗑️ Deprecations
- Method
BigDecimal::hasNonZeroFractionalPart()is deprecated, use->getFractionalPart()->isZero()instead
-
0.15.020 Feb 2026Release notes
Open source →💥 Breaking changes
- floating-point inputs are no longer accepted by
of()and arithmetic methods, useof((string) $float)to get the same behaviour as before (#105) BigRationalis now always simplified to lowest terms: all operations, includingof()andofFraction(), now return a fraction in its simplest form (e.g.2/3instead of4/6)BigDecimal::dividedBy()now requires the$scaleparameterBigInteger::sqrt()andBigDecimal::sqrt()now default toRoundingMode::Unnecessary, explicitly passRoundingMode::Downto get the previous behaviourBigInteger::mod()now uses Euclidean modulo semantics: the modulus must be strictly positive, and the result is always non-negative; this change aligns with Java'sBigInteger.mod()behaviourBigInteger::mod(),modInverse()andmodPow()now throwInvalidArgumentException(instead ofNegativeNumberException) for negative modulus/exponent argumentsMathExceptionis now an interface instead of a classBigDecimal::getPrecision()now returns1for zero valuesBigNumber::min(),max()andsum()now throw anArgumentCountErrorwhen called with no arguments (previously threwInvalidArgumentException)BigInteger::randomBits()andrandomRange()now throwRandomSourceExceptionwhen random byte generation fails or returns invalid data
Deprecated API elements removed:
- deprecated method
BigInteger::testBit()has been removed, useisBitSet()instead - deprecated method
BigInteger::gcdMultiple()has been removed, usegcdAll()instead - deprecated method
BigDecimal::exactlyDividedBy()has been removed, usedividedByExact()instead - deprecated method
BigDecimal::getIntegralPart()has been removed (will be re-introduced as returningBigIntegerin 0.16) - deprecated method
BigDecimal::getFractionalPart()has been removed (will be re-introduced as returningBigDecimalwith a different meaning in 0.16) - deprecated method
BigDecimal::stripTrailingZeros()has been removed, usestrippedOfTrailingZeros()instead - deprecated method
BigRational::nd()has been removed, useofFraction()instead - deprecated method
BigRational::quotient()has been removed, usegetIntegralPart()instead - deprecated method
BigRational::remainder()has been removed, use$number->getNumerator()->remainder($number->getDenominator())instead - deprecated method
BigRational::quotientAndRemainder()has been removed, use$number->getNumerator()->quotientAndRemainder($number->getDenominator())instead - deprecated
RoundingModeupper snake case constants (e.g.HALF_UP) have been removed, use the pascal case version (e.g.HalfUp) instead
The following breaking changes only affect you if you're using named arguments:
BigInteger::mod()now uses$modulusas the parameter nameBigInteger::modInverse()now uses$modulusas the parameter nameBigInteger::modPow()now uses$exponentand$modulusas parameter namesBigInteger::shiftedLeft()now uses$bitsas the parameter nameBigInteger::shiftedRight()now uses$bitsas the parameter nameBigInteger::isBitSet()now uses$bitIndexas the parameter nameBigInteger::randomBits()now uses$bitCountas the parameter nameBigDecimal::withPointMovedLeft()now uses$placesas the parameter nameBigDecimal::withPointMovedRight()now uses$placesas the parameter name
The following breaking changes are unlikely to affect you:
DivisionByZeroException::modulusMustNotBeZero()has been renamed tozeroModulus()DivisionByZeroException::denominatorMustNotBeZero()has been renamed tozeroDenominator()IntegerOverflowException::toIntOverflow()has been renamed tointegerOutOfRange()RoundingNecessaryException::roundingNecessary()has been removed
🗑️ Deprecations
- Method
BigRational::simplified()is deprecated, as it is now a no-op
✨ New features
BigInteger::power(),BigDecimal::power()andBigRational::power()no longer enforce an exponent limitBigInteger::shiftedLeft()andBigInteger::shiftedRight()no longer enforce a limit on the number of bitsBigRational::power()now accepts negative exponents- New exception:
InvalidArgumentExceptionfor invalid argument errors - New exception:
NoInverseExceptionfor modular inverse errors - New exception:
RandomSourceExceptionfor random source errors
👌 Improvements
Release notes
Open source →💥 Breaking changes
- floating-point inputs are no longer accepted by
of()and arithmetic methods, useof((string) $float)to get the same behaviour as before (#105) BigRationalis now always simplified to lowest terms: all operations, includingof()andofFraction(), now return a fraction in its simplest form (e.g.2/3instead of4/6)BigDecimal::dividedBy()now requires the$scaleparameterBigInteger::sqrt()andBigDecimal::sqrt()now default toRoundingMode::Unnecessary, explicitly passRoundingMode::Downto get the previous behaviourBigInteger::mod()now uses Euclidean modulo semantics: the modulus must be strictly positive, and the result is always non-negative; this change aligns with Java'sBigInteger.mod()behaviourBigInteger::mod(),modInverse()andmodPow()now throwInvalidArgumentException(instead ofNegativeNumberException) for negative modulus/exponent argumentsMathExceptionis now an interface instead of a classBigDecimal::getPrecision()now returns1for zero valuesBigNumber::min(),max()andsum()now throw anArgumentCountErrorwhen called with no arguments (previously threwInvalidArgumentException)BigInteger::randomBits()andrandomRange()now throwRandomSourceExceptionwhen random byte generation fails or returns invalid data
Deprecated API elements removed:
- deprecated method
BigInteger::testBit()has been removed, useisBitSet()instead - deprecated method
BigInteger::gcdMultiple()has been removed, usegcdAll()instead - deprecated method
BigDecimal::exactlyDividedBy()has been removed, usedividedByExact()instead - deprecated method
BigDecimal::getIntegralPart()has been removed (will be re-introduced as returningBigIntegerin 0.16) - deprecated method
BigDecimal::getFractionalPart()has been removed (will be re-introduced as returningBigDecimalwith a different meaning in 0.16) - deprecated method
BigDecimal::stripTrailingZeros()has been removed, usestrippedOfTrailingZeros()instead - deprecated method
BigRational::nd()has been removed, useofFraction()instead - deprecated method
BigRational::quotient()has been removed, usegetIntegralPart()instead - deprecated method
BigRational::remainder()has been removed, use$number->getNumerator()->remainder($number->getDenominator())instead - deprecated method
BigRational::quotientAndRemainder()has been removed, use$number->getNumerator()->quotientAndRemainder($number->getDenominator())instead - deprecated
RoundingModeupper snake case constants (e.g.HALF_UP) have been removed, use the pascal case version (e.g.HalfUp) instead
The following breaking changes only affect you if you're using named arguments:
BigInteger::mod()now uses$modulusas the parameter nameBigInteger::modInverse()now uses$modulusas the parameter nameBigInteger::modPow()now uses$exponentand$modulusas parameter namesBigInteger::shiftedLeft()now uses$bitsas the parameter nameBigInteger::shiftedRight()now uses$bitsas the parameter nameBigInteger::isBitSet()now uses$bitIndexas the parameter nameBigInteger::randomBits()now uses$bitCountas the parameter nameBigDecimal::withPointMovedLeft()now uses$placesas the parameter nameBigDecimal::withPointMovedRight()now uses$placesas the parameter name
The following breaking changes are unlikely to affect you:
DivisionByZeroException::modulusMustNotBeZero()has been renamed tozeroModulus()DivisionByZeroException::denominatorMustNotBeZero()has been renamed tozeroDenominator()IntegerOverflowException::toIntOverflow()has been renamed tointegerOutOfRange()RoundingNecessaryException::roundingNecessary()has been removed
🗑️ Deprecations
- Method
BigRational::simplified()is deprecated, as it is now a no-op
✨ New features
BigInteger::power(),BigDecimal::power()andBigRational::power()no longer enforce an exponent limitBigInteger::shiftedLeft()andBigInteger::shiftedRight()no longer enforce a limit on the number of bitsBigRational::power()now accepts negative exponents- New exception:
InvalidArgumentExceptionfor invalid argument errors - New exception:
NoInverseExceptionfor modular inverse errors - New exception:
RandomSourceExceptionfor random source errors
👌 Improvements
- Narrowed parameter and return types with static analysis annotations (#108 by @simPod)
- floating-point inputs are no longer accepted by
-
0.14.810 Feb 2026Release notes
Open source →🗑️ Deprecations
- Method
BigInteger::testBit()is deprecated, useisBitSet()instead
✨ New features
- New method:
BigInteger::isBitSet()(replacestestBit()) - New method:
BigNumber::toString()(alias of magic method__toString())
👌 Improvements
- Performance optimization of
BigRationalcomparison methods - More exceptions have been documented with
@throwsannotations
- Method
-
0.14.707 Feb 2026Release notes
Open source →✨ New features
clamp()is now available on the baseBigNumberclass
👌 Improvements
- Improved
@throwsexception documentation
-
0.14.605 Feb 2026Release notes
Open source →🗑️ Deprecations
- Not passing a
$scaletoBigDecimal::dividedBy()is deprecated;$scalewill be required in 0.15
👌 Improvements
BigRational::toFloat()never returnsNANanymore
- Not passing a
-
0.14.503 Feb 2026Release notes
Open source →🗑️ Deprecations
- Not passing a rounding mode to
BigInteger::sqrt()andBigDecimal::sqrt()triggers a deprecation notice: the default rounding mode will change fromDowntoUnnecessaryin 0.15
✨ New features
BigInteger::sqrt()andBigDecimal::sqrt()now support roundingabs()andnegated()methods are now available on the baseBigNumberclass
👌 Improvements
- Alphabet is now checked for duplicate characters in
BigInteger::(from|to)ArbitraryBase() BigNumber::ofNullable()is now marked as@pure
- Not passing a rounding mode to
-
0.14.402 Feb 2026Release notes
Open source →🗑️ Deprecations
- Passing a negative modulus to
BigInteger::mod()is deprecated to align with Euclidean modulo semantics; it will throwInvalidArgumentExceptionin 0.15 - Method
BigDecimal::stripTrailingZeros()is deprecated, usestrippedOfTrailingZeros()instead
✨ New features
BigInteger::modPow()now accepts negative bases- New method:
BigDecimal::strippedOfTrailingZeros()(replacesstripTrailingZeros())
👌 Improvements
clamp()methods are now marked as@pure
- Passing a negative modulus to
-
0.14.301 Feb 2026Release notes
Open source →✨ New features
- New method:
BigInteger::lcm() - New method:
BigInteger::lcmAll() - New method:
BigRational::toRepeatingDecimalString()
🐛 Bug fixes
BigInteger::gcdAll()/gcdMultiple()could return a negative result when used with a single negative number
- New method:
-
0.14.230 Jan 2026Release notes
Open source →🗑️ Deprecations
- Passing
floatvalues toof()or arithmetic methods is deprecated and will be removed in 0.15; cast to string explicitly to preserve the previous behaviour (#105) - Accessing
RoundingModeenum cases through upper snake case (e.g.HALF_UP) is deprecated, use the pascal case version (e.g.HalfUp) instead - Method
BigInteger::gcdMultiple()is deprecated, usegcdAll()instead - Method
BigDecimal::exactlyDividedBy()is deprecated, usedividedByExact()instead - Method
BigDecimal::getIntegralPart()is deprecated (will be removed in 0.15, and re-introduced as returningBigIntegerin 0.16) - Method
BigDecimal::getFractionalPart()is deprecated (will be removed in 0.15, and re-introduced as returningBigDecimalwith a different meaning in 0.16) - Method
BigRational::nd()is deprecated, useofFraction()instead - Method
BigRational::quotient()is deprecated, usegetIntegralPart()instead - Method
BigRational::remainder()is deprecated, use$number->getNumerator()->remainder($number->getDenominator())instead - Method
BigRational::quotientAndRemainder()is deprecated, use$number->getNumerator()->quotientAndRemainder($number->getDenominator())instead
✨ New features
- New method:
BigInteger::gcdAll()(replacesgcdMultiple()) - New method:
BigRational::clamp() - New method:
BigRational::ofFraction()(replacesnd()) - New method:
BigRational::getIntegralPart()(replacesquotient()) - New method:
BigRational::getFractionalPart()
👌 Improvements
- All exceptions thrown by the library now implement a common
MathExceptioninterface BigInteger::modInverse()now acceptsBigNumber|int|float|stringinstead of justBigIntegerBigInteger::gcdMultiple()now acceptsBigNumber|int|float|stringinstead of justBigInteger
🐛 Bug fixes
BigInteger::clamp()andBigDecimal::clamp()now throw an exception on inverted bounds, instead of returning an incorrect result
- Passing
-
0.14.124 Nov 2025Release notes
Open source →✨ New features
- New method:
BigNumber::ofNullable()(#94 by @mrkh995)
✨ Compatibility fixes
- Fixed warnings on PHP 8.5 (#101 and #102 by @julien-boudry)
- New method:
-
0.14.029 Aug 2025Release notes
Open source →✨ New features
- New methods:
BigInteger::clamp()andBigDecimal::clamp()(#96 by @JesterIruka)
✨ Improvements
- All pure methods in
BigNumberclasses are now marked as@purefor better static analysis
💥 Breaking changes
- Minimum PHP version is now 8.2
BigNumberclasses are nowreadonlyBigNumberis now marked as sealed: it must not be extended outside of this package- Exception classes are now
final
- New methods:
-
0.13.129 Mar 2025Release notes
Open source →✨ Improvements
__toString()methods ofBigIntegerandBigDecimalare now type-hinted as returningnumeric-stringinstead ofstring(#90 by @vudaltsov)
-
0.13.003 Mar 2025Release notes
Open source →💥 Breaking changes
BigDecimal::ofUnscaledValue()no longer throws an exception if the scale is negativeMathExceptionnow extendsRuntimeExceptioninstead ofException; this reverts the change introduced in version0.11.0(#82)
✨ New features
BigDecimal::ofUnscaledValue()allows a negative scale (and converts the values to create a zero scale number)
-
0.12.328 Feb 2025Release notes
Open source →✨ New features
BigDecimal::getPrecision()Returns the number of significant digits in a decimal number
-
0.12.226 Feb 2025Release notes
Open source →⚡️ Performance improvements
- Division in
NativeCalculatoris now faster for small divisors, thanks to @Izumi-kun in #87.
👌 Improvements
- Add missing
RoundingNecessaryExceptionto the@throwsannotation ofBigNumber::of()
- Division in
-
0.12.129 Nov 2023Release notes
Open source →⚡️ Performance improvements
BigNumber::of()is now faster, thanks to @SebastienDug in #77.
-
0.12.026 Nov 2023Release notes
Open source →💥 Breaking changes
- Minimum PHP version is now 8.1
RoundingModeis now anenum; if you're type-hinting rounding modes, you need to type-hint againstRoundingModeinstead ofintnowBigNumberclasses do not implement theSerializableinterface anymore (they use the new custom object serialization mechanism)- The following breaking changes only affect you if you're creating your own
BigNumbersubclasses:- the return type of
BigNumber::of()is nowstatic BigNumberhas a new abstract methodfrom()- all
publicandprotectedfunctions ofBigNumberare nowfinal
- the return type of
-
0.11.015 Jan 2023Release notes
Open source →💥 Breaking changes
- Minimum PHP version is now 8.0
- Methods accepting a union of types are now strongly typed<sup>*</sup>
MathExceptionnow extendsExceptioninstead ofRuntimeException
<sup>* You may now run into type errors if you were passing
Stringableobjects toof()or any of the methods internally callingof(), withstrict_typesenabled. You can fix this by castingStringableobjects tostringfirst.</sup> -
0.10.210 Aug 2022Release notes
Open source →👌 Improvements
BigRational::toFloat()now simplifies the fraction before performing division (#73) thanks to @olsavmic
-
0.10.101 Aug 2022Release notes
Open source →✨ New features
BigInteger::gcdMultiple()returns the GCD of multipleBigIntegernumbers
-
0.10.018 Jun 2022 -
0.9.315 Aug 2021Release notes
Open source →🚀 Compatibility with PHP 8.1
- Support for custom object serialization; this removes a warning on PHP 8.1 due to the
Serializableinterface being deprecated (#60) thanks @TRowbotham
- Support for custom object serialization; this removes a warning on PHP 8.1 due to the
-
0.9.220 Jan 2021Release notes
Open source →🐛 Bug fix
- Incorrect results could be returned when using the BCMath calculator, with a default scale set with
bcscale(), on PHP >= 7.2 (#55).
- Incorrect results could be returned when using the BCMath calculator, with a default scale set with
-
0.9.118 Aug 2020Release notes
Open source →✨ New features
BigInteger::not()returns the bitwiseNOTvalue
🐛 Bug fixes
BigInteger::toBytes()could return an incorrect binary representation for some numbers- The bitwise operations
and(),or(),xor()onBigIntegercould return an incorrect result when the GMP extension is not available
-
0.9.018 Aug 2020Release notes
Open source →👌 Improvements
BigNumber::of()now accepts.123and123.formats, both of which return aBigDecimal
💥 Breaking changes
- Deprecated method
BigInteger::powerMod()has been removed - usemodPow()instead - Deprecated method
BigInteger::parse()has been removed - usefromBase()instead
-
0.8.1718 Aug 2020Release notes
Open source →🐛 Bug fix
BigInteger::toBytes()could return an incorrect binary representation for some numbers- The bitwise operations
and(),or(),xor()onBigIntegercould return an incorrect result when the GMP extension is not available
-
0.8.1618 Aug 2020Release notes
Open source →🚑 Critical fix
- This version reintroduces the deprecated
BigInteger::parse()method, that has been removed by mistake in version0.8.9and should have lasted for the whole0.8release cycle.
✨ New features
BigInteger::modInverse()calculates a modular multiplicative inverseBigInteger::fromBytes()creates aBigIntegerfrom a byte stringBigInteger::toBytes()converts aBigIntegerto a byte stringBigInteger::randomBits()creates a pseudo-randomBigIntegerof a given bit lengthBigInteger::randomRange()creates a pseudo-randomBigIntegerbetween two bounds
💩 Deprecations
BigInteger::powerMod()is now deprecated in favour ofmodPow()
- This version reintroduces the deprecated
-
0.8.1515 Apr 2020Release notes
Open source →🐛 Fixes
- added missing
ext-jsonrequirement, due toBigNumberimplementingJsonSerializable
⚡️ Optimizations
- additional optimization in
BigInteger::remainder()
- added missing
-
0.8.1417 Feb 2020Release notes
Open source →✨ New features
BigInteger::getLowestSetBit()returns the index of the rightmost one bit
-
0.8.1316 Feb 2020Release notes
Open source →✨ 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 number
-
0.8.1227 Jan 2020Release notes
Open source →🛠️ 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.
-
0.8.1123 Jan 2020Release notes
Open source →✨ New feature
BigInteger::powerMod()performs a power-with-modulo operation. Useful for crypto. -
0.8.1021 Jan 2020Release notes
Open source →✨ New feature
BigInteger::mod()returns the modulo of two numbers. The modulo differs from the remainder when the signs of the operands are different. -
0.8.908 Jan 2020Release notes
Open source →⚡️ Performance improvements
A few additional optimizations in
BigIntegerandBigDecimalwhen one of the operands can be returned as is. Thanks to @tomtomsen in #24. -
0.8.825 Apr 2019Release notes
Open source →🐛 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 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 offromBase()
BigInteger::fromBase()works the same way asparse(), with 2 minor differences:- the
$baseparameter is required, it does not default to10 - it throws a
NumberFormatExceptioninstead of anInvalidArgumentExceptionwhen the number is malformed
-
0.8.719 Apr 2019Release notes
Open source →Improvements
- Safer conversion from
floatwhen using custom locales - Much faster
NativeCalculatorimplementation 🚀
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.
- Safer conversion from
-
0.8.611 Apr 2019 -
0.8.512 Feb 2019Release notes
Open source →Bug fix:
of()factory methods could fail when passing afloatin environments using aLC_NUMERIClocale with a decimal separator other than'.'(#20).Thanks @manowark 👍
-
0.8.407 Dec 2018Release notes
Open source →New method
BigDecimal::sqrt()calculates the square root of a decimal number, to a given scale. -
0.8.306 Dec 2018Release notes
Open source →New method
BigInteger::sqrt()calculates the square root of a number (thanks @peter279k).New exception
NegativeNumberExceptionis thrown when callingsqrt()on a negative number. -
0.8.207 Nov 2018Release notes
Open source →Performance update
- Further improvement of
toInt()performance NativeCalculatorcan now perform some multiplications more efficiently
- Further improvement of
-
0.8.107 Nov 2018 -
0.8.013 Oct 2018Release notes
Open source →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
BigIntegerhas been augmented with 5 new methods for bitwise operations:New method Description and()performs a bitwise ANDoperation on two numbersor()performs a bitwise ORoperation on two numbersxor()performs a bitwise XORoperation on two numbersshiftedLeft()returns the number shifted left by a number of bits shiftedRight()returns the number shifted right by a number of bits Thanks to @DASPRiD 👍
-
0.7.320 Aug 2018Release notes
Open source →New method:
BigDecimal::hasNonZeroFractionalPart()Renamed/deprecated methods:
BigDecimal::getIntegral()has been renamed togetIntegralPart()and is now deprecatedBigDecimal::getFraction()has been renamed togetFractionalPart()and is now deprecated
-
0.7.221 Jul 2018Release notes
Open source →Performance update
BigInteger::parse()andtoBase()now use GMP's built-in base conversion features when available. -
0.7.127 Feb 2018Release notes
Open source →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.
- When installed with
-
0.7.002 Oct 2017Release notes
Open source →Methods renamed:
BigNumber:sign()has been renamed togetSign()BigDecimal::unscaledValue()has been renamed togetUnscaledValue()BigDecimal::scale()has been renamed togetScale()BigDecimal::integral()has been renamed togetIntegral()BigDecimal::fraction()has been renamed togetFraction()BigRational::numerator()has been renamed togetNumerator()BigRational::denominator()has been renamed togetDenominator()
Classes renamed:
ArithmeticExceptionhas been renamed toMathException
-
0.6.202 Oct 2017Release notes
Open source →The base class for all exceptions is now
MathException.ArithmeticExceptionhas been deprecated, and will be removed in 0.7.0. -
0.6.102 Oct 2017Release notes
Open source →A number of methods have been renamed:
BigNumber:sign()is deprecated; usegetSign()insteadBigDecimal::unscaledValue()is deprecated; usegetUnscaledValue()insteadBigDecimal::scale()is deprecated; usegetScale()insteadBigDecimal::integral()is deprecated; usegetIntegral()insteadBigDecimal::fraction()is deprecated; usegetFraction()insteadBigRational::numerator()is deprecated; usegetNumerator()insteadBigRational::denominator()is deprecated; usegetDenominator()instead
The old methods will be removed in version 0.7.0.
-
0.6.025 Aug 2017Release notes
Open source →- Minimum PHP version is now 7.1; for PHP 5.6 and PHP 7.0 support, use version
0.5 - Deprecated method
BigDecimal::withScale()has been removed; usetoScale()instead - Method
BigNumber::toInteger()has been renamed totoInt()
- Minimum PHP version is now 7.1; for PHP 5.6 and PHP 7.0 support, use version
-
0.5.417 Oct 2016Release notes
Open source →BigNumberclasses now implement JsonSerializable. The JSON output is always a string. -
0.5.331 Mar 2016Release notes
Open source →This is a bugfix release. Dividing by a negative power of 1 with the same scale as the dividend could trigger an incorrect optimization which resulted in a wrong result. See #6.