为什么sin()没有返回正确的值? [英] Why doesn't sin() return the correct value?

查看:214
本文介绍了为什么sin()没有返回正确的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 sin() cos() tan () iOS应用程序中的函数?当我使用它们时,我没有得到正确的值。示例:

How do I use the sin(), cos(), and tan() functions in iOS application? When I use them I don't get the correct value. Example:

double value=sin(90);

我得到的价值:0.893997但预期值:1。我该如何解决这个问题?

I got value: 0.893997 but expected value: 1. How can I fix this?

推荐答案

问题是它的正弦值是90 弧度,而不是。尝试 sin(M_PI_2) 90°。

The problem is that it's taking the sine of 90 radians, not degrees. Try sin(M_PI_2) for 90°.

这篇关于为什么sin()没有返回正确的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆