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

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