home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boston 2
/
boston-2.iso
/
DOS
/
PROGRAM
/
CLIPPER
/
NFTROFF
/
10.TR
< prev
next >
Wrap
Text File
|
1993-12-01
|
7KB
|
418 lines
.de }n
.bp
.sp .5i
..
.wh -.8i }n
.sp .5i
.po -.4i
.ll 7.5i
.ps 9
.vs 9
.in 0i
.ta 1.63265i
.sp 2
.ne 20
.ps +3
.vs +3
FT_GCD() Calculate greatest common divisor of two numbers
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_GCD()
Calculate greatest common divisor of two numbers
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.4i
\fBFT_GCD( <nNumber1>, <nNumber2> ) -> nGCD
.sp
.in 0.08i
\fBArguments
.sp
.in 0.4i
\fB<nNumber1>\fR is the first number to find the GCD of\.
.sp
\fB<nNumber2>\fR is the second number to find the GCD of\.
.sp
.in 0.08i
\fBReturns
.sp
.in 0.4i
The greatest common divisor of the 2 numbers, or 0 if either is 0\.
.sp
.in 0.08i
\fBDescription
.sp
.in 0.24i
This function calculates the greatest common divisor between 2 numbers,
i\.e\., the largest number that will divide into both numbers evenly\. It
will return zero (0) if either number is zero\.
.sp
.in 0.08i
\fBExamples
.sp
.in 0.4i
.ta 2.64i
.br
? FT_GCD(10,15) // Result: 5
.br
.ta
.ta 2.64i
.br
? FT_GCD(108,54) // Result: 54
.br
.ta
.ta 2.64i
.br
? FT_GCD(102,54) // Result: 6
.br
.ta
.ta 2.64i
.br
? FT_GCD(111,17) // Result: 1
.br
.ta
.sp
.in 0.08i
\fBSource:\fR GCD\.PRG
.sp
\fBAuthor:\fR David Husnian
.in 0i
.ta 1.63265i
.sp 2
.ne 20
.ps +3
.vs +3
FT_NETPV() Calculate net present value
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_NETPV()
Calculate net present value
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.4i
\fBFT_NETPV( <nInitialInvestment>, <nInterestRate>, <aCashFlow> ;
.in 1.2i
\fB[, <nNoOfCashFlows> ] ) -> nNetPV
.sp
.in 0.08i
\fBArguments
.sp
.in 0.4i
\fB<nInitialInvestment>\fR is the amount of cash invested for purposes
of generating the cash flows\.
.sp
\fB<nInterestRate>\fR is the annual interest rate used to discount
expected cash flows (10\.5% = 10\.5, not \.105)\.
.sp
\fB<aCashFlow>\fR is an array of the expected cash receipts each year\.
.sp
\fB<nNoOfCashFlows>\fR is the number of years cash flows are expected
(optional, Len( aCashFlow ) )\.
.sp
.in 0.08i
\fBReturns
.sp
.in 0.4i
The difference between the initial investment and the discounted
cash flow in dollars\.
.sp
.in 0.08i
\fBDescription
.sp
.in 0.4i
This function calculates the net present value, the difference
between the cost of an initial investment and the present value
of the expected cash flow(s) from the investment\. The present
value of the expected cashflow(s) is calculated at the specified
interest rate, which is often referred to as the "cost of capital"\.
.sp
This function can be used to evaluate alternative investments\.
The larger the NPV, the more profitable the investment\. See
also the FutureValue and PresentValue for further explanations\.
The formula to calculate the net present value is:
.sp
NetPresentValue = SUM(CashFlow[i] / ((1 + InterestRate) ** i))
.in 1.84i
FOR i = 1 TO NoOfCashFlows
.sp
.in 0.08i
\fBExamples
.sp
.in 0.4i
nNetPresentValue := FT_NETPV(10000, 10, { 10000,15000,16000,17000 } )
.sp
.in 0.08i
\fBSource:\fR NETPV\.PRG
.sp
\fBAuthor:\fR David Husnian
.in 0i
.ta 1.63265i
.sp 2
.ne 20
.ps +3
.vs +3
FT_RAND1() Generate a random number
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_RAND1()
Generate a random number
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.4i
\fBFT_RAND1( <nMax> ) -> nRand
.sp
.in 0.08i
\fBArguments
.sp
.in 0.4i
.ta 0.64i
\fB<nMax>\fR Maximum limit of value to be produced\.
.br
.ta
.sp
.in 0.08i
\fBReturns
.sp
.in 0.4i
nRand is a random number between 0 (inclusive) and <nMax> (exclusive)\.
.sp
.in 0.08i
\fBDescription
.sp
.in 0.4i
Generates a non-integer random number based on the Linear
Congruential Method\.
.sp
If you need a random number between 1 and <nMax> inclusive, INT()
the result and add 1\.
.sp
If you need a random number between 0 and <nMax> inclusive,
then you should ROUND() the result\.
.sp
.in 0.08i
\fBExamples
.sp
.in 0.48i
.ta 3.12i
.br
nResult := INT( FT_RAND1(100) ) + 1 // 1 <= nResult <= 100
.br
.ta
.ta 3.12i
.br
nResult := ROUND( FT_RAND1(100), 0 ) // 0 <= nResult <= 100
.br
.ta
.ta 3.12i
.br
nResult := FT_RAND1( 1 ) // 0 <= nResult < 1
.br
.ta
.sp
.in 0.08i
\fBSource:\fR RAND1\.PRG
.sp
\fBAuthor:\fR Gary Baren
.in 0i
.ta 1.63265i
.sp 2
.ne 20
.ps +3
.vs +3
FT_ROUND() Rounds a number to a specific place
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_ROUND()
Rounds a number to a specific place
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.4i
.ta 4i
\fBFT_ROUND( <nNumber> [, <nRoundToAmount> ;
.br
.ta
.in 1.2i
.ta 1.36i 3.2i
\fB[, <cRoundType> [, <cRoundDirection> ;
.br
.ta
.ta 3.44i
\fB[, <nAcceptableError> ] ] ] ] ) -> nNumber
.br
.ta
.sp
.in 0.08i
\fBArguments
.sp
.in 0.4i
\fB<nNumber>\fR is the number to round
.sp
\fB<nRoundToAmount>\fR is the fraction to round to or the number of places,
default is 2\.
.sp
\fB<cRoundType>\fR is the type of rounding desired
.sp
.in 0.64i
.ta 1.76i 4i
.br
"D" for Decimal (3 for thousandth, 1/1000) (default)
.br
.ta
.ta 1.76i
.br
"F" for Fraction (3 for thirds, 1/3)
.br
.ta
.br
"W" for Whole numbers (3 for thousand, 1000)
.sp
.in 0.4i
\fB<cRoundDirection>\fR is the direction to round the number toward
.sp
.in 0.64i
.ta 1.68i 2.4i
.br
"U" to round Up 1\.31 -> \fB1\.4
.br
.ta
.in 2.24i
.br
-1\.31 -> \fB-1\.4
.in 0.64i
.ta 1.68i 2.4i
.br
"D" to round Down 1\.36 -> \fB1\.3
.br
.ta
.in 2.24i
.br
-1\.36 -> \fB-1\.3
.in 0.64i
.ta 1.68i 2.08i 2.4i
.br
"N" to round Normal 1\.5 -> \fB2
.br
.ta
.in 2.24i
.ta 0.48i
.br
-1\.5 -> \fB-2
.br
.ta
.in 2.32i
.ta 0.72i
.br
1\.49 -> \fB1
.br
.ta
.in 2.24i
.br
-1\.49 -> \fB-1
.sp
.in 0.4i
\fB<nAcceptableError>\fR 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
.sp
.in 0.08i
\fBReturns
.sp
.in 0.4i
The number, rounded as specified\.
.sp
.in 0.08i
\fBDescription
.sp
.in 0.4i
This function will allow you to round a number\. The following can
be specified:
.in 0.56i
.br
a\. Direction (up, down or normal - normal is 4/5 convention)
.br
b\. Type (whole, decimal, fraction)
.br
c\. Amount (100\'s, 5 decimals, 16th, etc\.)
.sp
.in 0.08i
\fBExamples
.sp
.in 0.4i
.br
// round normal to 2 decimal places
.br
nDollars := FT_ROUND(nDollars)
.sp
.br
// round normal to 6 decimal places
.br
nIntRate := FT_ROUND(nIntRate, 6)
.sp
.br
// round to nearest thousands
.ta 0.72i
.br
nPrice := FT_ROUND(nPrice, 3, NEAREST_WHOLE_NUMBER)
.br
.ta
.sp
.br
// round Up to nearest third
.ta 0.72i
.br
nAmount := FT_ROUND(nAmount, 3, NEAREST_FRACTION, ROUND_UP)
.br
.ta
.sp
.br
// round down to 3 decimals Within \.005
.ta 0.72i
.br
nAvg := FT_ROUND(nAvg, 3, , ROUND_DOWN, \.005)
.br
.ta
.sp
.in 0.08i
\fBSource:\fR ROUND\.PRG
.sp
\fBAuthor:\fR David Husnian