I have a strange problem with the standard cos cmath / math.h function. Apparently, in some circumstances, it returns an incorrect or just an undefined value.
#include <cmath>
#include <iostream>
int main()
{
double foo = 8.0 * 0.19634955;
double bla = std::cos(foo);
std::cout << bla << std::endl;
return 0;
}
If the input value for cos is 1.5707964, for example, cos returns -7.32051e-008 (doubles when using, with floats -4.XYZe-009).
I missed something really simple and simple here ...?
source
share