这个问题在这里已经有了答案:
Math.Cos&Math.Sin在C# 5中的答案我正在尝试使用Math.Sin()来计算sin(pi弧度)。 我正在使用下面的代码。
double degrees = 180; double radians = Math.PI / 180 * degrees; Console.WriteLine(Math.Sin(radians));它给了我一个值
1.22460635382238E-16
这是什么原因? 当然,它应该返回一个值为0的权利?
请赐教。 谢谢。
This question already has an answer here:
Math.Cos & Math.Sin in C# 7 answersI am trying to calculate sin(pi radians) using Math.Sin(). I am using the following code.
double degrees = 180; double radians = Math.PI / 180 * degrees; Console.WriteLine(Math.Sin(radians));It is giving me a value of
1.22460635382238E-16
What is the reason for this? Surely it should be returning a value of 0 right?
Please enlighten me. Thanks.
最满意答案
1.22460635382238E-16基本上是0.它实际上代表了数字
0.000000000000000122460635382238。 这个数字接近于0.这基本上只是因为所有不同的舍入错误。
请参阅http://en.wikipedia.org/wiki/Floating_point以获取更多信息。
1.22460635382238E-16 basically is 0. it actually represents the number
0.000000000000000122460635382238. This number is close to 0. It's basically just because of different rounding errors all coming together.
take a look at http://en.wikipedia.org/wiki/Floating_point for more information.
更多推荐
发布评论