Skip to content

Releases: brick/math

0.14.3

01 Feb 15:22

Choose a tag to compare

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

0.14.2

30 Jan 14:05

Choose a tag to compare

🗑️ Deprecations

  • Passing float values to of() or arithmetic methods is deprecated and will be removed in 0.15; cast to string explicitly to preserve the previous behaviour (#105)
  • Accessing RoundingMode enum 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, use gcdAll() instead
  • Method BigDecimal::exactlyDividedBy() is deprecated, use dividedByExact() instead
  • Method BigDecimal::getIntegralPart() is deprecated (will be removed in 0.15, and re-introduced as returning BigInteger in 0.16)
  • Method BigDecimal::getFractionalPart() is deprecated (will be removed in 0.15, and re-introduced as returning BigDecimal with a different meaning in 0.16)
  • Method BigRational::nd() is deprecated, use ofFraction() instead
  • Method BigRational::quotient() is deprecated, use getIntegralPart() 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() (replaces gcdMultiple())
  • New method: BigRational::clamp()
  • New method: BigRational::ofFraction() (replaces nd())
  • New method: BigRational::getIntegralPart() (replaces quotient())
  • New method: BigRational::getFractionalPart()

👌 Improvements

  • BigInteger::modInverse() now accepts BigNumber|int|float|string instead of just BigInteger
  • BigInteger::gcdMultiple() now accepts BigNumber|int|float|string instead of just BigInteger

🐛 Bug fixes

  • BigInteger::clamp() and BigDecimal::clamp() now throw an exception on inverted bounds, instead of returning an incorrect result

0.14.1

24 Nov 14:42

Choose a tag to compare

New features

  • New method: BigNumber::ofNullable() (#94 by @mrkh995)

Compatibility fixes

0.14.0

29 Aug 12:50

Choose a tag to compare

New features

  • New methods: BigInteger::clamp() and BigDecimal::clamp() (#96 by @JesterIruka)

Improvements

  • All pure methods in BigNumber classes are now marked as @pure for better static analysis

💥 Breaking changes

  • Minimum PHP version is now 8.2
  • BigNumber classes are now readonly
  • BigNumber is now marked as sealed: it must not be extended outside of this package
  • Exception classes are now final

0.13.1

29 Mar 13:51

Choose a tag to compare

Improvements

  • __toString() methods of BigInteger and BigDecimal are now type-hinted as returning numeric-string instead of string (#90 by @vudaltsov)

0.13.0

03 Mar 13:22

Choose a tag to compare

💥 Breaking changes

  • BigDecimal::ofUnscaledValue() no longer throws an exception if the scale is negative
  • MathException now extends RuntimeException instead of Exception; this reverts the change introduced in version 0.11.0 (#82)

New features

  • BigDecimal::ofUnscaledValue() allows a negative scale (and converts the values to create a zero scale number)

0.12.3

28 Feb 13:12

Choose a tag to compare

New features

  • BigDecimal::getPrecision() returns the number of significant digits in a decimal number

0.12.2

26 Feb 10:24

Choose a tag to compare

⚡️ Performance improvements

  • Division in NativeCalculator is now faster for small divisors, thanks to @Izumi-kun in #87

👌 Improvements

  • Add missing RoundingNecessaryException to the @throws annotation of BigNumber::of()

0.12.1

29 Nov 23:22

Choose a tag to compare

⚡️ Performance improvements

0.12.0

26 Nov 14:45

Choose a tag to compare

💥 Breaking changes

  • Minimum PHP version is now 8.1
  • RoundingMode is now an enum; if you're type-hinting rounding modes, you need to type-hint against RoundingMode instead of int now
  • BigNumber classes do not implement the Serializable interface anymore (they use the new custom object serialization mechanism)
  • The following breaking changes only affect you if you're creating your own BigNumber subclasses:
    • the return type of BigNumber::of() is now static
    • BigNumber has a new abstract method from()
    • all public and protected functions of BigNumber are now final