Arbitrary-precision arithmetic library for PHP
MIT License
Bot releases are hidden (Show)
Published by BenMorel over 5 years ago
Improvements
float
when using custom localesNativeCalculator
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.
Published by BenMorel over 5 years ago
New method
BigNumber::sum()
returns the sum of one or more numbers.
Published by BenMorel over 5 years ago
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 👍
Published by BenMorel almost 6 years ago
New method
BigDecimal::sqrt()
calculates the square root of a decimal number, to a given scale.
Published by BenMorel almost 6 years ago
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.
Published by BenMorel almost 6 years ago
Performance update
toInt()
performanceNativeCalculator
can now perform some multiplications more efficientlyPublished by BenMorel almost 6 years ago
Performance optimization of toInt()
methods.
Published by BenMorel about 6 years ago
Breaking changes
The following deprecated methods have been removed. Use the new method name instead:
Method removed | Replacement method |
---|---|
BigDecimal::getIntegral() |
BigDecimal::getIntegralPart() |
BigDecimal::getFraction() |
BigDecimal::getFractionalPart() |
New features
BigInteger
has been augmented with 5 new methods for bitwise operations:
New method | Description |
---|---|
and() |
performs a bitwise AND operation on two numbers |
or() |
performs a bitwise OR operation on two numbers |
xor() |
performs a bitwise XOR operation on two numbers |
shiftedLeft() |
returns the number shifted left by a number of bits |
shiftedRight() |
returns the number shifted right by a number of bits |
Thanks to @DASPRiD 👍
Published by BenMorel about 6 years ago
New method: BigDecimal::hasNonZeroFractionalPart()
Renamed/deprecated methods:
BigDecimal::getIntegral()
has been renamed to getIntegralPart()
and is now deprecatedBigDecimal::getFraction()
has been renamed to getFractionalPart()
and is now deprecatedPublished by BenMorel about 6 years ago
Performance update
BigInteger::parse()
and toBase()
now use GMP's built-in base conversion features when available.
Published by BenMorel over 6 years ago
This is a maintenance release, no code has been changed.
--no-dev
, the autoloader does not autoload tests anymoreThis will help make installations more compact.
Published by BenMorel about 7 years ago
Methods renamed:
BigNumber:sign()
has been renamed to getSign()
BigDecimal::unscaledValue()
has been renamed to getUnscaledValue()
BigDecimal::scale()
has been renamed to getScale()
BigDecimal::integral()
has been renamed to getIntegral()
BigDecimal::fraction()
has been renamed to getFraction()
BigRational::numerator()
has been renamed to getNumerator()
BigRational::denominator()
has been renamed to getDenominator()
Classes renamed:
ArithmeticException
has been renamed to MathException
Published by BenMorel about 7 years ago
The base class for all exceptions is now MathException
.
ArithmeticException
has been deprecated, and will be removed in 0.7.0.
Published by BenMorel about 7 years ago
A number of methods have been renamed:
BigNumber:sign()
is deprecated; use getSign()
insteadBigDecimal::unscaledValue()
is deprecated; use getUnscaledValue()
insteadBigDecimal::scale()
is deprecated; use getScale()
insteadBigDecimal::integral()
is deprecated; use getIntegral()
insteadBigDecimal::fraction()
is deprecated; use getFraction()
insteadBigRational::numerator()
is deprecated; use getNumerator()
insteadBigRational::denominator()
is deprecated; use getDenominator()
insteadThe old methods will be removed in version 0.7.0.
Published by BenMorel about 8 years ago
BigNumber
classes now implement JsonSerializable.
The JSON output is always a string.
Published by BenMorel over 8 years ago
Backport of two bug fixes from the 0.5 branch:
BigInteger::parse()
did not always throw InvalidArgumentException
as expectedPublished by BenMorel over 8 years ago
Backport of two bug fixes from the 0.5 branch:
BigInteger::parse()
did not always throw InvalidArgumentException
as expectedPublished by BenMorel over 8 years ago
This is a bugfix release. Dividing by a negative power of 1 with the same scale as the dividend could trigger an incorrect optimization which resulted in a wrong result. See #6.
Published by BenMorel about 9 years ago
The $scale
parameter of BigDecimal::dividedBy()
is now optional again.