home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / PROGRAM / CLIPPER / NFTROFF / 10.TR < prev    next >
Text File  |  1993-12-01  |  7KB  |  418 lines

  1. .de }n
  2. .bp
  3. .sp .5i
  4. ..
  5. .wh -.8i }n
  6. .sp .5i
  7. .po -.4i
  8. .ll 7.5i
  9. .ps 9
  10. .vs 9
  11. .in 0i
  12. .ta 1.63265i
  13. .sp 2
  14. .ne 20
  15. .ps +3
  16. .vs +3
  17. FT_GCD()    Calculate greatest common divisor of two numbers
  18. .br
  19. .ta
  20. .in 0.08i
  21. .ps -3
  22. .vs -3
  23. .sp 2
  24. \fBFT_GCD()
  25. Calculate greatest common divisor of two numbers
  26. .in 0i
  27. .br
  28. \l'6.24i'
  29. .br
  30. .sp
  31. .in 0.08i
  32. \fBSyntax
  33. .sp
  34. .in 0.4i
  35. \fBFT_GCD( <nNumber1>, <nNumber2> ) -> nGCD
  36. .sp
  37. .in 0.08i
  38. \fBArguments
  39. .sp
  40. .in 0.4i
  41. \fB<nNumber1>\fR is the first number to find the GCD of\.
  42. .sp
  43. \fB<nNumber2>\fR is the second number to find the GCD of\.
  44. .sp
  45. .in 0.08i
  46. \fBReturns
  47. .sp
  48. .in 0.4i
  49. The greatest common divisor of the 2 numbers, or 0 if either is 0\.
  50. .sp
  51. .in 0.08i
  52. \fBDescription
  53. .sp
  54. .in 0.24i
  55. This function calculates the greatest common divisor between 2 numbers,
  56. i\.e\., the largest number that will divide into both numbers evenly\.  It
  57. will return zero (0) if either number is zero\.
  58. .sp
  59. .in 0.08i
  60. \fBExamples
  61. .sp
  62. .in 0.4i
  63. .ta 2.64i
  64. .br
  65. ? FT_GCD(10,15)    // Result: 5
  66. .br
  67. .ta
  68. .ta 2.64i
  69. .br
  70. ? FT_GCD(108,54)    // Result: 54
  71. .br
  72. .ta
  73. .ta 2.64i
  74. .br
  75. ? FT_GCD(102,54)    // Result: 6
  76. .br
  77. .ta
  78. .ta 2.64i
  79. .br
  80. ? FT_GCD(111,17)    // Result: 1
  81. .br
  82. .ta
  83. .sp
  84. .in 0.08i
  85. \fBSource:\fR GCD\.PRG
  86. .sp
  87. \fBAuthor:\fR David Husnian
  88. .in 0i
  89. .ta 1.63265i
  90. .sp 2
  91. .ne 20
  92. .ps +3
  93. .vs +3
  94. FT_NETPV()    Calculate net present value
  95. .br
  96. .ta
  97. .in 0.08i
  98. .ps -3
  99. .vs -3
  100. .sp 2
  101. \fBFT_NETPV()
  102. Calculate net present value
  103. .in 0i
  104. .br
  105. \l'6.24i'
  106. .br
  107. .sp
  108. .in 0.08i
  109. \fBSyntax
  110. .sp
  111. .in 0.4i
  112. \fBFT_NETPV( <nInitialInvestment>, <nInterestRate>, <aCashFlow> ;
  113. .in 1.2i
  114. \fB[, <nNoOfCashFlows> ] ) -> nNetPV
  115. .sp
  116. .in 0.08i
  117. \fBArguments
  118. .sp
  119. .in 0.4i
  120. \fB<nInitialInvestment>\fR is the amount of cash invested for purposes
  121. of generating the cash flows\.
  122. .sp
  123. \fB<nInterestRate>\fR is the annual interest rate used to discount
  124. expected cash flows (10\.5% = 10\.5, not \.105)\.
  125. .sp
  126. \fB<aCashFlow>\fR is an array of the expected cash receipts each year\.
  127. .sp
  128. \fB<nNoOfCashFlows>\fR is the number of years cash flows are expected
  129. (optional, Len( aCashFlow ) )\.
  130. .sp
  131. .in 0.08i
  132. \fBReturns
  133. .sp
  134. .in 0.4i
  135. The difference between the initial investment and the discounted
  136. cash flow in dollars\.
  137. .sp
  138. .in 0.08i
  139. \fBDescription
  140. .sp
  141. .in 0.4i
  142. This function calculates the net present value, the difference
  143. between the cost of an initial investment and the present value
  144. of the expected cash flow(s) from the investment\.  The present
  145. value of the expected cashflow(s) is calculated at the specified
  146. interest rate, which is often referred to as the "cost of capital"\.
  147. .sp
  148. This function can be used to evaluate alternative investments\.
  149. The larger the NPV, the more profitable the investment\.  See
  150. also the FutureValue and PresentValue for further explanations\.
  151. The formula to calculate the net present value is:
  152. .sp
  153. NetPresentValue = SUM(CashFlow[i] / ((1 + InterestRate) ** i))
  154. .in 1.84i
  155. FOR i = 1 TO NoOfCashFlows
  156. .sp
  157. .in 0.08i
  158. \fBExamples
  159. .sp
  160. .in 0.4i
  161. nNetPresentValue := FT_NETPV(10000, 10, { 10000,15000,16000,17000 } )
  162. .sp
  163. .in 0.08i
  164. \fBSource:\fR NETPV\.PRG
  165. .sp
  166. \fBAuthor:\fR David Husnian
  167. .in 0i
  168. .ta 1.63265i
  169. .sp 2
  170. .ne 20
  171. .ps +3
  172. .vs +3
  173. FT_RAND1()    Generate a random number
  174. .br
  175. .ta
  176. .in 0.08i
  177. .ps -3
  178. .vs -3
  179. .sp 2
  180. \fBFT_RAND1()
  181. Generate a random number
  182. .in 0i
  183. .br
  184. \l'6.24i'
  185. .br
  186. .sp
  187. .in 0.08i
  188. \fBSyntax
  189. .sp
  190. .in 0.4i
  191. \fBFT_RAND1( <nMax> ) -> nRand
  192. .sp
  193. .in 0.08i
  194. \fBArguments
  195. .sp
  196. .in 0.4i
  197. .ta 0.64i
  198. \fB<nMax>\fR    Maximum limit of value to be produced\.
  199. .br
  200. .ta
  201. .sp
  202. .in 0.08i
  203. \fBReturns
  204. .sp
  205. .in 0.4i
  206. nRand is a random number between 0 (inclusive) and <nMax> (exclusive)\.
  207. .sp
  208. .in 0.08i
  209. \fBDescription
  210. .sp
  211. .in 0.4i
  212. Generates a non-integer random number based on the Linear
  213. Congruential Method\.
  214. .sp
  215. If you need a random number between 1 and <nMax> inclusive, INT()
  216. the result and add 1\.
  217. .sp
  218. If you need a random number between 0 and <nMax> inclusive,
  219. then you should ROUND() the result\.
  220. .sp
  221. .in 0.08i
  222. \fBExamples
  223. .sp
  224. .in 0.48i
  225. .ta 3.12i
  226. .br
  227. nResult := INT( FT_RAND1(100) ) + 1    // 1 <= nResult <= 100
  228. .br
  229. .ta
  230. .ta 3.12i
  231. .br
  232. nResult := ROUND( FT_RAND1(100), 0 )    // 0 <= nResult <= 100
  233. .br
  234. .ta
  235. .ta 3.12i
  236. .br
  237. nResult := FT_RAND1( 1 )    // 0 <= nResult < 1
  238. .br
  239. .ta
  240. .sp
  241. .in 0.08i
  242. \fBSource:\fR RAND1\.PRG
  243. .sp
  244. \fBAuthor:\fR Gary Baren
  245. .in 0i
  246. .ta 1.63265i
  247. .sp 2
  248. .ne 20
  249. .ps +3
  250. .vs +3
  251. FT_ROUND()    Rounds a number to a specific place
  252. .br
  253. .ta
  254. .in 0.08i
  255. .ps -3
  256. .vs -3
  257. .sp 2
  258. \fBFT_ROUND()
  259. Rounds a number to a specific place
  260. .in 0i
  261. .br
  262. \l'6.24i'
  263. .br
  264. .sp
  265. .in 0.08i
  266. \fBSyntax
  267. .sp
  268. .in 0.4i
  269. .ta 4i
  270. \fBFT_ROUND( <nNumber> [, <nRoundToAmount>    ;
  271. .br
  272. .ta
  273. .in 1.2i
  274. .ta 1.36i 3.2i
  275. \fB[, <cRoundType>    [, <cRoundDirection>    ;
  276. .br
  277. .ta
  278. .ta 3.44i
  279. \fB[, <nAcceptableError> ] ] ] ] )    -> nNumber
  280. .br
  281. .ta
  282. .sp
  283. .in 0.08i
  284. \fBArguments
  285. .sp
  286. .in 0.4i
  287. \fB<nNumber>\fR is the number to round
  288. .sp
  289. \fB<nRoundToAmount>\fR is the fraction to round to or the number of places,
  290. default is 2\.
  291. .sp
  292. \fB<cRoundType>\fR is the type of rounding desired
  293. .sp
  294. .in 0.64i
  295. .ta 1.76i 4i
  296. .br
  297. "D" for Decimal    (3 for thousandth, 1/1000)    (default)
  298. .br
  299. .ta
  300. .ta 1.76i
  301. .br
  302. "F" for Fraction    (3 for thirds, 1/3)
  303. .br
  304. .ta
  305. .br
  306. "W" for Whole numbers (3 for thousand, 1000)
  307. .sp
  308. .in 0.4i
  309. \fB<cRoundDirection>\fR is the direction to round the number toward
  310. .sp
  311. .in 0.64i
  312. .ta 1.68i 2.4i
  313. .br
  314. "U" to round Up    1\.31 ->    \fB1\.4
  315. .br
  316. .ta
  317. .in 2.24i
  318. .br
  319. -1\.31 -> \fB-1\.4
  320. .in 0.64i
  321. .ta 1.68i 2.4i
  322. .br
  323. "D" to round Down    1\.36 ->    \fB1\.3
  324. .br
  325. .ta
  326. .in 2.24i
  327. .br
  328. -1\.36 -> \fB-1\.3
  329. .in 0.64i
  330. .ta 1.68i 2.08i 2.4i
  331. .br
  332. "N" to round Normal    1\.5    ->    \fB2
  333. .br
  334. .ta
  335. .in 2.24i
  336. .ta 0.48i
  337. .br
  338. -1\.5    -> \fB-2
  339. .br
  340. .ta
  341. .in 2.32i
  342. .ta 0.72i
  343. .br
  344. 1\.49 ->    \fB1
  345. .br
  346. .ta
  347. .in 2.24i
  348. .br
  349. -1\.49 -> \fB-1
  350. .sp
  351. .in 0.4i
  352. \fB<nAcceptableError>\fR is the amount that is considered acceptable
  353. to be within, i\.e\., if you\'re within this amount of the number
  354. you don\'t need to round
  355. .sp
  356. .in 0.08i
  357. \fBReturns
  358. .sp
  359. .in 0.4i
  360. The number, rounded as specified\.
  361. .sp
  362. .in 0.08i
  363. \fBDescription
  364. .sp
  365. .in 0.4i
  366. This function will allow you to round a number\.  The following can
  367. be specified:
  368. .in 0.56i
  369. .br
  370. a\. Direction (up, down or normal - normal is 4/5 convention)
  371. .br
  372. b\. Type (whole, decimal, fraction)
  373. .br
  374. c\. Amount (100\'s, 5 decimals, 16th, etc\.)
  375. .sp
  376. .in 0.08i
  377. \fBExamples
  378. .sp
  379. .in 0.4i
  380. .br
  381. // round normal to 2 decimal places
  382. .br
  383. nDollars := FT_ROUND(nDollars)
  384. .sp
  385. .br
  386. // round normal to 6 decimal places
  387. .br
  388. nIntRate := FT_ROUND(nIntRate, 6)
  389. .sp
  390. .br
  391. // round to nearest thousands
  392. .ta 0.72i
  393. .br
  394. nPrice    := FT_ROUND(nPrice, 3, NEAREST_WHOLE_NUMBER)
  395. .br
  396. .ta
  397. .sp
  398. .br
  399. // round Up to nearest third
  400. .ta 0.72i
  401. .br
  402. nAmount    := FT_ROUND(nAmount, 3, NEAREST_FRACTION, ROUND_UP)
  403. .br
  404. .ta
  405. .sp
  406. .br
  407. // round down to 3 decimals Within \.005
  408. .ta 0.72i
  409. .br
  410. nAvg    := FT_ROUND(nAvg, 3, , ROUND_DOWN, \.005)
  411. .br
  412. .ta
  413. .sp
  414. .in 0.08i
  415. \fBSource:\fR ROUND\.PRG
  416. .sp
  417. \fBAuthor:\fR David Husnian
  418.