开发者

cos result incorrect

开发者 https://www.devze.com 2023-01-03 04:00 出处:网络
I import \"math.h\". I can use the cos function, but when I execute cos(0.321139585333178)开发者_运维问答

I import "math.h".

I can use the cos function, but when I execute cos(0.321139585333178)开发者_运维问答 the result is 0.948876

If I use the calculator in Mac or use a normal calculator, the result is 0.999984292347418

Can anyone help me to solve that problem?


You're confusing degrees with radians.

cos(0.321139585333178 degrees) = 0.999984292

cos(0.321139585333178 radians) = 0.948876326

  • To convert from radians to degrees, multiply by 180/π.
  • To convert from degrees to radians, multiply by π/180.
0

精彩评论

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