FT_ROUND()
Rounds a number to a specific place
──────────────────────────────────────────────────────────────────────────────
Syntax
FT_ROUND( <nNumber> [, <nRoundToAmount> ;
[, <cRoundType> [, <cRoundDirection> ;
[, <nAcceptableError> ] ] ] ] ) -> nNumber
Arguments
<nNumber> is the number to round
<nRoundToAmount> is the fraction to round to or the number of places,
default is 2.
<cRoundType> is the type of rounding desired
"D" for Decimal (3 for thousandth, 1/1000) (default)
"F" for Fraction (3 for thirds, 1/3)
"W" for Whole numbers (3 for thousand, 1000)
<cRoundDirection> is the direction to round the number toward
"U" to round Up 1.31 -> 1.4
-1.31 -> -1.4
"D" to round Down 1.36 -> 1.3
-1.36 -> -1.3
"N" to round Normal 1.5 -> 2
-1.5 -> -2
1.49 -> 1
-1.49 -> -1
<nAcceptableError> is the amount that is considered acceptable
to be within, i.e., if you're within this amount of the number
you don't need to round
Returns
The number, rounded as specified.
Description
This function will allow you to round a number. The following can
be specified:
a. Direction (up, down or normal - normal is 4/5 convention)
b. Type (whole, decimal, fraction)
c. Amount (100's, 5 decimals, 16th, etc.)
Examples
// round normal to 2 decimal places
nDollars := FT_ROUND(nDollars)
// round normal to 6 decimal places
nIntRate := FT_ROUND(nIntRate, 6)
// round to nearest thousands
nPrice := FT_ROUND(nPrice, 3, NEAREST_WHOLE_NUMBER)
// round Up to nearest third
nAmount := FT_ROUND(nAmount, 3, NEAREST_FRACTION, ROUND_UP)
// round down to 3 decimals Within .005
nAvg := FT_ROUND(nAvg, 3, , ROUND_DOWN, .005)
Source: ROUND.PRG
Author: David Husnian