Function roundDecimal( x, dp )
- Description:
-
Rounds a value to a given number of decimal places.
The result is a
float
(32-bit floating point value),
so this is only suitable for relatively low-precision values.
It's intended for truncating the number of apparent significant
figures represented by a value which you know has been obtained
by combining other values of limited precision.
For more control, see the functions in the Formats
class.
- Parameters:
-
- x (floating point)
- a floating point value
- dp (integer)
- number of decimal places (digits after the decimal point)
to retain
- Return Value (floating point):
- floating point value close to
x
but with a
limited apparent precision
- Example:
roundDecimal(PI,2) = 3.14f
- Signature:
- float roundDecimal(double, int)