Oihana PHP

maths

Table of Contents

Functions

ceilValue()  : int|float
Rounds and returns the ceiling of the specified number or expression.
floorValue()  : int|float
Rounds and returns a number by a count of floating points, using floor.
roundValue()  : int|float
Rounds and returns the rounded value of the specified number or expression.

Functions

ceilValue()

Rounds and returns the ceiling of the specified number or expression.

ceilValue(int|float $value[, int $floatCount = 0 ]) : int|float

The ceiling of a number is the closest integer that is greater than or equal to the number.

Parameters
$value : int|float

The number to round.

$floatCount : int = 0

The number of decimal places to round up to.

Tags
example
echo ceilValue(4.1234);       // Outputs: 5
echo ceilValue(4.1234, 2);    // Outputs: 4.13
echo ceilValue(4.9999, 3);    // Outputs: 5.000
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
int|float

The rounded number.

floorValue()

Rounds and returns a number by a count of floating points, using floor.

floorValue(int|float $value[, int $floatCount = 0 ]) : int|float

The floor of a number is the closest integer less than or equal to the number.

Parameters
$value : int|float

The number to round.

$floatCount : int = 0

The number of decimal places to round down to.

Tags
example
echo floorValue(4.9876);       // Outputs: 4
echo floorValue(4.9876, 2);    // Outputs: 4.98
echo floorValue(4.1234, 3);    // Outputs: 4.123
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
int|float

The rounded number.

roundValue()

Rounds and returns the rounded value of the specified number or expression.

roundValue(int|float $value[, int $floatCount = 0 ]) : int|float
Parameters
$value : int|float

The number to round.

$floatCount : int = 0

The number of decimal places to round to.

Tags
example
echo roundValue(4.9876);       // Outputs: 5
echo roundValue(4.9876, 2);    // Outputs: 4.99
echo roundValue(4.1234, 3);    // Outputs: 4.123
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
int|float

The rounded number.


        
On this page

Search results