I am working in a project where I must interface between managed code and unmanaged code. I am currently having a strange issue with math.h.
Some functions will floating numbers will returns 0 (ex: 2.1219957934356005e-314) and randomly...
By example:
int error = 0;
int success = 0;
for (int i = 0; i < 1000; ++i)
{
double test = std::sqrt(9.01);
if (test < 2 || test > 4)
{
++error;
}
else
{
++success;
}
}
Usually I will obtain error = 1000 with breakpoints, I'll retry it some times and get again 1000 errors and some times I will get 1000 success...
I see nothing wrong into the dissassembly and into the registers (except the bad result).
For context: this code is compiled into a dll for 64 bits and is used by C#. This app is indeed multithreaded.
Any idea?