开发者

Math library in iPhone SDK?

I m trying to calculate this equation for a small iphone app:

x = 120 x num^-1.123 x tr^-0.206 x [te] x [fe]

x equals 120 times num raised to the power of -1.123 times tr raised to the power of -0.206 times te times fe.

Where num, tr, te and fe are known numbers entered by the user.

How do I do that? I m stuck in the negative decimal power of num and tr.

开发者_开发问答

any help appreciated...


Foundation will include math functions, so all you have to do is use one of the pow() functions to work with. Use pow() for working with doubles, powf() for floats, or powl() for long doubles. Here's an example:

double num = 2.0;
double tr = 3.0;
double te = 4.0;
double fe = 5.0;

double x = 120.0 * pow(num, -1.123) * pow(tr, -0.206) * te * fe;


The iPhone SDK contains the standard C library functions (math.h) that you could use for these kind of math. Searching for math.h in your XCode documentation should show all the related functions (like pow for raising x to the power of y).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜