Skip to content

Releases: brick/math

0.20.0

Choose a tag to compare

@BenMorel BenMorel released this 28 Aug 20:57

πŸ’₯ Breaking changes

  • Deprecated exception class UnsupportedPlatformException has been removed, catch PlatformException instead

The following breaking change only affects you if you specifically catch DivisionByZeroException around calls to of() or to any method accepting strings:

  • of() now throws NumberFormatException instead of DivisionByZeroException when the string is a fraction with a denominator of zero, such as '2/0'

✨ New features

  • New methods: parse() and parseNullable() safely parse untrusted input, by restricting the allowed syntax and limiting the number of digits
  • New enum: NumberSyntax lists the syntax features that parse() can accept, with constants for the most common combinations

πŸ› Bug fixes

  • of() no longer throws PlatformException on malformed input with many digits, crafted to trigger heavy backtracking in its parser; such input now throws NumberFormatException as documented

πŸ‘Œ Improvements

  • NumberFormatException messages now escape control and non-ASCII characters, and truncate values longer than 40 bytes, instead of copying the raw input into the message

0.19.1

Choose a tag to compare

@BenMorel BenMorel released this 08 Aug 23:05

✨ New features

  • New exception class: PlatformException (replaces UnsupportedPlatformException)
  • PlatformException is now thrown when preg_match() fails due to improper PHP configuration
  • PlatformException is now thrown when PHP_INT_SIZE is an unsupported value

πŸ—‘οΈ Deprecations

  • Exception class UnsupportedPlatformException is deprecated; catch PlatformException instead

0.19.0

Choose a tag to compare

@BenMorel BenMorel released this 30 Jul 22:07

✨ New features

  • New rounding mode: RoundingMode::HalfOdd
  • New method: RoundingMode::fromNativeRoundingMode() converts from a native PHP RoundingMode enum (PHP 8.4+)

0.18.0

Choose a tag to compare

@BenMorel BenMorel released this 14 Jun 18:50

πŸ’₯ Breaking changes

The following breaking change only affects you if you're using named arguments:

  • BigInteger::fromBytes() now uses $bytes as the parameter name

πŸ› Bug fixes

  • of() no longer accepts a trailing newline (\n) in the input string; such input now throws NumberFormatException
  • of() now consistently throws NumberFormatException for exponents too large to process, instead of IntegerOverflowException in some cases
  • BigInteger::fromBase() now reports the invalid character with its original case in the NumberFormatException message, instead of lower-casing it

⚑️ Performance improvements

  • BigInteger::gcd() no longer exhausts memory on large inputs when the GMP extension is not installed
  • BigInteger::modInverse() no longer exhausts memory on large inputs, and is faster when the GMP extension is not installed

πŸ‘Œ Static analysis improvements

  • Narrowed parameter and return types with static analysis annotations:
    • nthRoot()'s $n is now positive-int
    • BigInteger::toBase(), toArbitraryBase(), toBytes() and BigRational::toRepeatingDecimalString() now return non-empty-string

0.17.2

Choose a tag to compare

@BenMorel BenMorel released this 25 May 20:42

✨ New features

  • New methods: BigInteger::nthRoot() and BigDecimal::nthRoot() compute the nth root of a number (#113 by @Pablo1Gustavo)

0.17.1

Choose a tag to compare

@BenMorel BenMorel released this 19 Apr 21:22

πŸ‘Œ Improvements

  • More precise float approximations in BigRational::toFloat()

0.17.0

Choose a tag to compare

@BenMorel BenMorel released this 17 Mar 13:03

πŸ’₯ 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

Choose a tag to compare

@BenMorel BenMorel released this 15 Mar 01:01

✨ New features

New methods to create a BigDecimal from a float value:

  • BigDecimal::fromFloatExact()
  • BigDecimal::fromFloatShortest()

0.16.1

Choose a tag to compare

@BenMorel BenMorel released this 09 Mar 13:49

πŸ‘Œ Improvements

  • Add @return non-empty-string to toString(), jsonSerialize() and __toString() (#111 by @vudaltsov)

0.16.0

Choose a tag to compare

@BenMorel BenMorel released this 06 Mar 13:30

πŸ’₯ Breaking changes

  • BigInteger::getLowestSetBit() now returns null instead of -1 when 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 as BigInteger (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 as BigDecimal (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