小编Ana*_*y B的帖子

c++ 和 c# sin 函数大值的不同结果

当我使用大数时,我遇到了 C# 中 Math.Sin 函数的这种奇怪行为;例如:

C#:.Net 4.7.2:Math.Sin(6.2831853071795856E+45) = 6.2831853071795856E+45

C++:sin(6.2831853071795856E+45) = -0.089650623841643268

任何想法如何获得与 C++ 相同的结果?

C# 示例:

double value = 6.2831853071795856E+45;    
Console.WriteLine(Math.Sin(value));
Run Code Online (Sandbox Code Playgroud)

C++ 示例:

double x = 6.2831853071795856E+45;
double result;
    
result = sin(x);
cout << "sin(x) = " << result << endl;
Run Code Online (Sandbox Code Playgroud)

.net c# c++ floating-point .net-4.7.2

23
推荐指数
3
解决办法
1035
查看次数

标签 统计

.net ×1

.net-4.7.2 ×1

c# ×1

c++ ×1

floating-point ×1