Different results between c++ and c# sin function with large values

  .net, .net-4.7.2, c++

I came across such strange behavior of the Math.Sin function in the c#, when I use large numbers, for example:

c# – .net 4.7.2: Math.Sin(6.2831853071795856E+45) = 6.2831853071795856E+45

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

Any ideas how to get the same results as c++?

c# sample:

double value = 6.2831853071795856E+45;    
Console.WriteLine(Math.Sin(value));

c++ sample:

  double x = 6.2831853071795856E+45;
  double result;

  result = sin(x);
  cout << "sin(x) = " << result << endl;

Source: Windows Questions C++

LEAVE A COMMENT