BcMath\Number::ceil

(PHP 8 >= 8.4.0)

BcMath\Number::ceil任意精度数値を切り上げる

説明

public BcMath\Number::ceil(): BcMath\Number

必要に応じて $this を切り上げ、 $this の次に大きい整数値を返します。

パラメータ

この関数にはパラメータはありません。

戻り値

結果を新しい BcMath\Number オブジェクトとして返します。 結果の BcMath\Number::scale は常に 0 になります。

例1 BcMath\Number::ceil() の例

<?php
$num1
= new BcMath\Number('4.3')->ceil();
$num2 = new BcMath\Number('9.999')->ceil();
$num3 = new BcMath\Number('-3.14')->ceil();

var_dump($num1, $num2, $num3);
?>

上の例の出力は以下となります。

object(BcMath\Number)#2 (2) {
  ["value"]=>
  string(1) "5"
  ["scale"]=>
  int(0)
}
object(BcMath\Number)#3 (2) {
  ["value"]=>
  string(2) "10"
  ["scale"]=>
  int(0)
}
object(BcMath\Number)#4 (2) {
  ["value"]=>
  string(2) "-3"
  ["scale"]=>
  int(0)
}

参考

add a note

User Contributed Notes

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