New features
- Common
BigNumberinterface for all classes, with the following methods:sign()and derived methods (isZero(),isPositive(), ...)compareTo()and derived methods (isEqualTo(),isGreaterThan(), ...) that work across differentBigNumbertypestoBigInteger(),toBigDecimal(),toBigRational() conversion methodstoInteger()andtoFloat()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()andremainder() - Fine-grained exceptions:
DivisionByZeroException,RoundingNecessaryException,NumberFormatException - Factory methods
zero(),one()andten()available in all classes - Rounding mode reintroduced in
BigInteger::dividedBy()
This release also comes with many performance improvements.
Breaking changes
BigInteger:getSign()is renamed tosign()toString()is renamed totoBase()BigInteger::dividedBy()now throws an exception by default if the remainder is not zero; usequotient()to get the previous behaviour
BigDecimal:getSign()is renamed tosign()getUnscaledValue()is renamed tounscaledValue()getScale()is renamed toscale()getIntegral()is renamed tointegral()getFraction()is renamed tofraction()divideAndRemainder()is renamed toquotientAndRemainder()dividedBy()now takes a mandatory$scaleparameter before the rounding modetoBigInteger()does not accept a$roundingModeparameter anymoretoBigRational()does not simplify the fraction anymore; explicitly add->simplified()to get the previous behaviour
BigRational:getSign()is renamed tosign()getNumerator()is renamed tonumerator()getDenominator()is renamed todenominator()of()is renamed tond(), whileparse()is renamed toof()
- Miscellaneous:
ArithmeticExceptionis moved to anException\sub-namespaceof()factory methods now throwNumberFormatExceptioninstead ofInvalidArgumentException