💥 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