Arbitrary Precision

8 entries

bcadd Function Adds two arbitrary-precision number strings and returns the result as a string. bccomp Function Compares two arbitrary-precision number strings and returns -1, 0 or 1. bcdiv Function Divides two arbitrary-precision number strings, truncating to the scale decimal places. bcmod Function Modulo of arbitrary-precision integers: operands and the result are number strings; a zero modulus throws DivisionByZeroError in PHP 8. bcmul / bcsub Function 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 Function An arbitrary-precision number raised to an integer power: results like 2^64, far beyond the int range, come back exactly as strings. bcscale Function 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 Function Integer division: the quotient truncates toward zero; dividing by zero throws DivisionByZeroError.