Download the PHP package ez-php/bignum without Composer
On this page you can find all versions of the php package ez-php/bignum. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ez-php/bignum
More information about ez-php/bignum
Files in ez-php/bignum
Package bignum
Short Description Arbitrary-precision integer and decimal arithmetic for the ez-php ecosystem — immutable BigInteger and BigDecimal value objects backed by bcmath (gmp optional)
License MIT
Homepage https://github.com/ez-php/bignum
Informations about the package bignum
ez-php/bignum
Arbitrary-precision integer and decimal arithmetic for PHP 8.5+.
Provides immutable BigInteger and BigDecimal value objects backed by PHP's built-in bcmath extension — no external Composer dependencies, no PECL extensions required. Optionally uses gmp as a faster backend for integer operations.
Installation
Requires ext-bcmath (ships with PHP). Optionally install ext-gmp for faster BigInteger arithmetic.
Quick Start
API
BigInteger
BigDecimal
RoundingMode
| Mode | Behaviour |
|---|---|
UP |
Round away from zero |
DOWN |
Round towards zero (truncate) |
CEILING |
Round towards positive infinity |
FLOOR |
Round towards negative infinity |
HALF_UP |
Round half away from zero (standard) |
HALF_DOWN |
Round half towards zero |
HALF_EVEN |
Round half to nearest even digit (banker's rounding) |
DivisionByZeroException
Thrown by divide, dividedBy, and mod when the divisor is zero. Extends \ArithmeticError.
Backend Selection
BigInteger auto-selects the best available backend:
- GmpBackend — used when
ext-gmpis loaded (faster for large integers) - BcMathBackend — always available fallback
BigDecimal always uses bcmath directly (GMP does not support decimal arithmetic).
To force a specific backend:
Design
- Zero framework coupling — usable standalone without bootstrapping the application
- Immutable — all operations return new instances; the original is never modified
- No
mixed— all parameters and return values are strictly typed - No external dependencies — only
ext-bcmath(required) andext-gmp(optional)
License
MIT
All versions of bignum with dependencies
ext-bcmath Version *