roundValue.php
Table of Contents
Functions
- roundValue() : float
- Rounds a number to a count of decimal places.
Functions
roundValue()
Rounds a number to a count of decimal places.
roundValue(int|float $value[, int $floatCount = 0 ]) : float
A decimal number is almost never exact in memory : 0.235 * 2.5 * 1000 holds 587.4999999999999,
and a naive round( $value * $r ) / $r falls to 0.587. The scaled value is therefore rounded to
six decimals first : a scaled value within one millionth of a half-way point is treated as
sitting exactly on it, so it rounds the way the exact arithmetic would.
Parameters
- $value : int|float
-
The number to round.
- $floatCount : int = 0
-
The number of decimal places to round to. A negative count is read as
0.
Tags
Return values
float —The rounded number.