Math.Tan不起作用 [英] Math.Tan does not work

查看:61
本文介绍了Math.Tan不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在为Windows Phone编写一个计算程序.一种计算方法是找到用户输入的数字的切线乘以用户输入的另一个数字.

I am currently writing a calculation program for the Windows Phone. One of the calculations if to find the tangent of a number the user enters times another number the user enters.

问题是当我键入1 * tan(45)(即1)时,它返回1.6....我在调试器中运行了几次.我可以看到45进入Math.Tan,输出为1.6.

The problem is when I typed in 1*tan(45) (which is 1) it returns 1.6.... I ran this through the debugger a couple of times. I can see 45 going into Math.Tan, and the output is 1.6.

请帮助我确定此问题的原因.下面的代码.

Please help me identify the cause of this problem. Code below.

double result;
double multiplying = Convert.ToDouble(txtMultTan.Text);
double tangent = Convert.ToDouble(txtTan.Text);
result = multiplying * (Math.Tan(tangent));
txtResult.Text = "Answer= " + result;

推荐答案

我确定,如果您阅读文档,将会发现trig函数期望输入以弧度为单位.要从度数转换为弧度,请使用数学库提供的任何预定义常量pi乘以pi/180.0.

I'm sure, if you read the documentation, you'll discover that the trig functions expect the input to be in radians. To convert from degrees to radians, multiply by pi/180.0, using whatever pre-defined constant of pi your math library offers.

这篇关于Math.Tan不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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