Arbitrary Precision
8 entries
bcadd
Adds two arbitrary-precision number strings and returns the result as a string.
bccomp
Compares two arbitrary-precision number strings and returns -1, 0 or 1.
bcdiv
Divides two arbitrary-precision number strings, truncating to the scale decimal places.
bcmod
Modulo of arbitrary-precision integers: operands and the result are number strings; a zero modulus throws DivisionByZeroError in PHP 8.
bcmul / bcsub
Completing the bcmath arithmetic family (alongside the existing bcadd/bcdiv/bcmod/bcpow/bcscale/bccomp) — strings in, strings out, with scale truncating decimal places; counterparts are BigDecimal/Decimal/big integers across languages, hand-written schoolbook arithmetic where absent.
bcpow
An arbitrary-precision number raised to an integer power: results like 2^64, far beyond the int range, come back exactly as strings.
bcscale
Sets the global default scale (decimal places) for the bcmath family, effective when a scale argument is omitted; returns the previous scale since PHP 8.
intdiv
Integer division: the quotient truncates toward zero; dividing by zero throws DivisionByZeroError.