目标C; asin问题

时间:2014-04-20 21:13:31

标签: ios objective-c

#import "ViewControllerSettings.h"
#define DEGREES(radians) (radians * 180 / M_PI)

NSLog(@"%f", sinFita);

sinFita = asin(DEGREES(sinFita));

NSLog(@"%f", sinFita);

返回

2014-04-20 22:10:09.916 ---[8561:60b] 0.239580
2014-04-20 22:10:09.920 ---[8561:60b] nan

我要求我的答案是以度数为单位,并使用doubles

答案应为13.86º

2 个答案:

答案 0 :(得分:1)

结果是正确的。逐步完成计算。当参数大于1时,您认为asin应该返回什么?

答案 1 :(得分:1)

asin参数应该是弧度而不是度数,asin返回的结果也是弧度,所以你需要按如下方式执行:

sinFita = DEGREES(asin(sinFita)); // Be aware that sinFita will now be in degrees and not in radians once this line is executed