Decimal v2.0.1
Stable release of the ext-decimal PHP extension with Rational number support.
(Version bumped from 2.0.0 which was previously published on PECL as alpha.)
Changes since v1.x
- Default decimal precision changed from 28 to 34 to match Decimal128.
- Decimal operations now use the minimum precision of all operands, rather than the maximum.
- Added
Decimal\Rationalimplementation for rational numbers (fractions). - Added
Decimal\Numberabstract number class. - Added
Decimal\Precisioninterface. - Added
Decimal\Decimal::reducemethod. - Renamed
toScitotoScientific. - Removed
signumandparitymethods. - Better consistency around scientific notation when converting to string or JSON.
- Precision is now applied on operations only (input is preserved).
- Decimal constructors are now private — must use
\Decimal\Number::valueOf. - Performance improvements, reduced object allocations.
- PHP 8.2, 8.3, and 8.4 compatibility.
- Fixed
isPositive/isNegativeto return false for zero values. - Fixed array/debug output for Decimal and Rational objects.
Requirements
- PHP >= 8.2
- libmpdec
Install
pecl install decimal
or via PIE:
pie install php-decimal/ext-decimal