Skip to content

0.5.0

Compare
Choose a tag to compare
@BenMorel BenMorel released this 04 Jul 20:43
· 366 commits to master since this release

New features

  • Common BigNumber interface for all classes, with the following methods:
    • sign() and derived methods (isZero(), isPositive(), ...)
    • compareTo() and derived methods (isEqualTo(), isGreaterThan(), ...) that work across different BigNumber types
    • toBigInteger(), toBigDecimal(), toBigRational() conversion methods
    • toInteger() and toFloat() conversion methods to native types
  • Unified of() behaviour: every class now accepts any type of number, provided that it can be safely converted to the current type
  • New method: BigDecimal::exactlyDividedBy(); this method automatically computes the scale of the result, provided that the division yields a finite number of digits
  • New methods: BigRational::quotient() and remainder()
  • Fine-grained exceptions: DivisionByZeroException, RoundingNecessaryException, NumberFormatException
  • Factory methods zero(), one() and ten() available in all classes
  • Rounding mode reintroduced in BigInteger::dividedBy()

This release also comes with many performance improvements.


Breaking changes

  • BigInteger:
    • getSign() is renamed to sign()
    • toString() is renamed to toBase()
    • BigInteger::dividedBy() now throws an exception by default if the remainder is not zero; use quotient() to get the previous behaviour
  • BigDecimal:
    • getSign() is renamed to sign()
    • getUnscaledValue() is renamed to unscaledValue()
    • getScale() is renamed to scale()
    • getIntegral() is renamed to integral()
    • getFraction() is renamed to fraction()
    • divideAndRemainder() is renamed to quotientAndRemainder()
    • dividedBy() now takes a mandatory $scale parameter before the rounding mode
    • toBigInteger() does not accept a $roundingMode parameter anymore
    • toBigRational() does not simplify the fraction anymore; explicitly add ->simplified() to get the previous behaviour
  • BigRational:
    • getSign() is renamed to sign()
    • getNumerator() is renamed to numerator()
    • getDenominator() is renamed to denominator()
    • of() is renamed to nd(), while parse() is renamed to of()
  • Miscellaneous:
    • ArithmeticException is moved to an Exception\ sub-namespace
    • of() factory methods now throw NumberFormatException instead of InvalidArgumentException