开发者

Future value function in iPhone SDK

I wanted a function which accepts present value, number of years and compound interest rate. It should return me the Future value based on these parameters.

You can see the exact thing that I am looking for at http://en.wikipedia.org/w开发者_如何学Goiki/Future_value (under To determine future value using compound interest)

Does Objective-C has any inbuilt function to do that. If no, could you please provide me any references to write that function.

Thanks in advance for all your help.


No, neither Objective-C nor Apple's frameworks include specific financial functions.

It's trivial to implement. The Wikipedia article you link to includes the formula. You might also want to consider something like QuantLib if you ever get onto more sophisticated calculations.

The formula -- copied from the Wikipedia article you linked to -- is:

FV = PV . (1 + i) ^ t

This can be converted into Objective-C mainly by typing:

  float fv, pv, i, t;

  pv = 200000.0; // present value
  i  = 0.012;    // interest rate (1.2%)
  t  = 5.0;      // time period

  fv = pv * pow (1.0 + i, t);


There would not be anything like this in Objective-C as Objective-C is a language, not a framework.

There's also nothing like this in Cocoa or Cocoa Touch, as they don't typically contain financial functions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜