The BcMath\Number class

Introduction

A class for an arbitrary precision number. These objects support overloaded arithmetic and comparison operators.

Note: This class is not affected by the bcmath.scale INI directive set in php.ini.

Note: The behavior of an overloaded operator is the same as specifying null for the scale parameter on the corresponding method.

Class synopsis

final readonly BcMath\Number
implements Stringable
/* Properties */
public string $value;
public int $scale;
/* Methods */
public __construct(stringint $num)
public BcMath\Number add(BcMath\Numberstringint $num, intnull $scale = null)
public BcMath\Number ceil()
public int compare(BcMath\Numberstringint $num, intnull $scale = null)
public BcMath\Number div(BcMath\Numberstringint $num, intnull $scale = null)
public array divmod(BcMath\Numberstringint $num, intnull $scale = null)
public BcMath\Number floor()
public BcMath\Number mod(BcMath\Numberstringint $num, intnull $scale = null)
public BcMath\Number mul(BcMath\Numberstringint $num, intnull $scale = null)
public BcMath\Number pow(BcMath\Numberstringint $exponent, intnull $scale = null)
public BcMath\Number powmod(BcMath\Numberstringint $exponent, BcMath\Numberstringint $modulus, intnull $scale = null)
public BcMath\Number round(int $precision = 0, RoundingMode $mode = RoundingMode::HalfAwayFromZero)
public array __serialize()
public BcMath\Number sqrt(intnull $scale = null)
public BcMath\Number sub(BcMath\Numberstringint $num, intnull $scale = null)
public string __toString()
public void __unserialize(array $data)

Properties

value
A string representation of an arbitrary precision number.
scale
The scale value currently set on the object. For objects resulting from calculations, this value is automatically computed and set, unless the scale parameter was set in the calculation method.
Table of Contents