update page now
PHP 8.5.4 Released!

The BcMath\Number class

(PHP 8 >= 8.4.0)

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

namespace BcMath;
final readonly class Number implements Stringable {
/* Properties */
public string $value;
public int $scale;
/* Methods */
public BcMath\Number::round(int $precision = 0, RoundingMode $mode = RoundingMode::HalfAwayFromZero): BcMath\Number
}

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

add a note

User Contributed Notes 1 note

up
5
harl at gmail dot com
11 months ago
BcMath\Number is one of those classes that overloads boolean casting.
If $z = new BcMath\Number(0) then $z is considered falsy (and hence, for example, empty($z)==true) even though it is a genuine Number object.
To Top