Releases: brick/math
0.8.11
0.8.10
0.8.9
0.8.8
🐛 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 alphabetBigInteger::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 offromBase()
BigInteger::fromBase()
works the same way as parse()
, with 2 minor differences:
- the
$base
parameter is required, it does not default to10
- it throws a
NumberFormatException
instead of anInvalidArgumentException
when the number is malformed
0.8.7
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
0.8.5
0.8.4
0.8.3
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.