Releases: brick/math
Releases · brick/math
0.15.0
💥 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
0.14.8
🗑️ 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
0.14.7
0.14.6
0.14.5
🗑️ 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
0.14.4
🗑️ 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
0.14.3
0.14.2
🗑️ 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
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
0.14.1
0.14.0
✨ 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