Skip to content

Releases: brick/math

0.8.11

23 Jan 00:35
Compare
Choose a tag to compare

New feature

BigInteger::powerMod() performs a power-with-modulo operation. Useful for crypto.

0.8.10

21 Jan 21:33
Compare
Choose a tag to compare

New feature

BigInteger::mod() returns the modulo of two numbers. The modulo differs from the remainder when the signs of the operands are different.

0.8.9

08 Jan 09:44
Compare
Choose a tag to compare

⚡️ Performance improvements

A few additional optimizations in BigInteger and BigDecimal when one of the operands can be returned as is. Thanks to @tomtomsen in #24.

0.8.8

25 Apr 15:21
Compare
Choose a tag to compare

🐛 Bug fixes

  • BigInteger::toBase() could return an empty string for zero values (BCMath & Native calculators only, GMP calculator unaffected)

New features

  • BigInteger::toArbitraryBase() converts a number to an arbitrary base, using a custom alphabet
  • BigInteger::fromArbitraryBase() converts a string in an arbitrary base, using a custom alphabet, back to a number

These methods can be used as the foundation to convert strings between different bases/alphabets, using BigInteger as an intermediate representation.

💩 Deprecations

  • BigInteger::parse() is now deprecated in favour of fromBase()

BigInteger::fromBase() works the same way as parse(), with 2 minor differences:

  • the $base parameter is required, it does not default to 10
  • it throws a NumberFormatException instead of an InvalidArgumentException when the number is malformed

0.8.7

20 Apr 22:39
Compare
Choose a tag to compare

Improvements

  • Safer conversion from float when using custom locales
  • Much faster NativeCalculator implementation 🚀

You can expect at least a 3x performance improvement for common arithmetic operations when using the library on systems without GMP or BCMath; it gets exponentially faster on multiplications with a high number of digits. This is due to calculations now being performed on whole blocks of digits (the block size depending on the platform, 32-bit or 64-bit) instead of digit-by-digit as before.

0.8.6

11 Apr 12:51
Compare
Choose a tag to compare

New method

BigNumber::sum() returns the sum of one or more numbers.

0.8.5

12 Feb 11:32
Compare
Choose a tag to compare

Bug fix: of() factory methods could fail when passing a float in environments using a LC_NUMERIC locale with a decimal separator other than '.' (#20).

Thanks @manowark 👍

0.8.4

07 Dec 15:17
Compare
Choose a tag to compare

New method

BigDecimal::sqrt() calculates the square root of a decimal number, to a given scale.

0.8.3

06 Dec 12:47
Compare
Choose a tag to compare

New method

BigInteger::sqrt() calculates the square root of a number (thanks @peter279k).

New exception

NegativeNumberException is thrown when calling sqrt() on a negative number.

0.8.2

08 Nov 09:54
Compare
Choose a tag to compare

Performance update

  • Further improvement of toInt() performance
  • NativeCalculator can now perform some multiplications more efficiently