BcMath\Number クラス

(PHP 8 >= 8.4.0)

はじめに

任意精度数値のクラスです。 このオブジェクトは、オーバーロードされた 算術演算子, 比較演算子 をサポートしています。

注意: このクラスは、php.iniで設定された bcmath.scale INI ディレクティブの影響を受けません。

注意: オーバーロードされた演算子の動作は、対応するメソッドで scale パラメータに null を指定した場合と同じです。

クラス概要

final readonly class BcMath\Number implements Stringable {
/* プロパティ */
public string $value;
public int $scale;
/* メソッド */
public __construct(string|int $num)
public compare(BcMath\Number|string|int $num, ?int $scale = null): int
public divmod(BcMath\Number|string|int $num, ?int $scale = null): array
public pow(BcMath\Number|string|int $exponent, ?int $scale = null): BcMath\Number
public powmod(BcMath\Number|string|int $exponent, BcMath\Number|string|int $modulus, ?int $scale = null): BcMath\Number
public round(int $precision = 0, RoundingMode $mode = RoundingMode::HalfAwayFromZero): BcMath\Number
public __serialize(): array
public sqrt(?int $scale = null): BcMath\Number
public __toString(): string
public __unserialize(array $data): void
}

プロパティ

value
任意精度数値の文字表現。
scale
オブジェクトに設定されているスケールの値。 計算メソッドで明示的に scale パラメータが設定されていない場合、 この値は自動的に計算されて設定されます。

目次

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top