php8.5
Home/ Manual/ bcmath / number/ BcMath\Number::floor

BcMath\Number::floor

PHP function Edit on GitHub ✎

(PHP 8 >= 8.4.0)

Rounds down an arbitrary precision number

Description

BcMath\Number::floor(): BcMath\Number

Returns the next highest integer value by rounding down $this if necessary.

Parameters Parameters

Examples

BcMath\Number::floor example

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

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

The above example will output:

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

See Also

  • bcfloor()
  • BcMath\Number::ceil
  • BcMath\Number::round

Source: reference/bc/bcmath/number/floor.xml · from the official PHP manual (php/doc-en)