Releases: brick/math
Releases Β· brick/math
0.17.0
π₯ 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
0.16.2
0.16.1
0.16.0
π₯ 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.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