From: Karl_Thompson@tigerfund.com Date: Fri, 3 Jan 1997 07:47:13 -0500 Subject: Delphi Bug List To: r.p.sterkenburg@dataweb.nl Cc: 72366.306@compuserve.com First, I would like to say that you are really doing a fine job editing the Delphi bug lists. I'm sure that your efforts are really appreciated. RE: Delphi 2.01 I noticed that one of the bugs you report is that the InternalRateOfReturn fuction in the Math unit calculates wrong answers. This does not appear to be the only function in the unit that has a problem. In fact, I can't find ANY financial function that works correctly. (Maybe you've already reported this.) If finished testing the following functions in addition to the InternalRateOfReturn (I've checked the results against Excel, but they seem to be so obvious, I don't know how the unit made it out of Borland like it is.): Z := NetPresentValue( 0.10, [1000], ptEndOfPeriod ); The result of the above should be 909.09. The function actually returns 1,000. After all, if an investment is made at the end of one period and the discount rate is 10% then the present value of the future amount must be less then the payment amount. 909.09 is the correct answer because if you work the formula in reverse, that is add 10% to the number, you are back at 1,000. That is, invest 909.09 today and at the end of the first period, it will be worth 1,000. NOTE: if you pass the function the array [0, 1000] the result of 909.09 is returned. Z := DoubleDecliningBalance( 10000, 0, 5, 1 ); The function returns 0.40 while the correct result is 4,000.00. Note that the depreciation for the second period is correct @2,400.00, but it is wrong again for periods 3 through 5. The correct answer of 4,000.00 can be easily calculated. The value (10,000) divided by the Life (5) equals 2,000, double that equals 4,000 depreciation for the first year. Z := FutureValue( 0.10, 1, 000, 100, {ptStartOfPeriod} ptEndOfPeriod ); First, this function returns a negative value. (I would hate to invest money at a positive rate and owe more money at the end of the period .) In this example, the function returns -110.00. Actually, the answer should be $100. If the period of investment is for one period, and the investment is made at the end of that period, then no interest is due. When the TPaymentTime parameter is set to ptStartOfPeriod, the correct amount of interest is accrued (10.00) but as I mentioned, a negative value is returned. Actually, the results do not appear to change whether the last parameter is set to ptStartOfPeriod or ptEndOfPeriod. I've not reviewed the code in the math unit, but it would appear that maybe there is a bug in a function that is being shared by these functions. Karl I'm sending along a PKZIP file of the sample project that I used to test these functions. You should recieve that as the next file. MATHBUGS.ZIP Also, the CC: e-mail address is a compuserve account. If you need to contact me, would you mind sending your e-mail to both addresses?