RoundDP Function
Returns X rounded to the given number of Decimal Places.

Unit
QESBPCSMath

Declaration
Function RoundDP(const X: Extended; const DecimalPlaces: ShortInt): Extended;

Description
When DecimalPlaces is negative then Integral places are implied, ie -2 would round to the nearest hundred. DecimalPlaces = 0 implies rounding to nearest Integer Value. Designed to work similar to the Round Function in MS Excel.

Parameters
Value to process.
DecimalPlaces Number of Decimal Places to round to.

Category
Arithmetic Routines for Floats

Implementation

function RoundDP (const X: Extended; const DecimalPlaces: ShortInt): Extended;
var
     Y: Extended;
begin
     Y := ESBIntPower (10, DecimalPlaces);
     Result := Round (X * Y) / Y;
End;


HTML generated by Time2HELP
http://www.time2help.com