How to reproduce this behavior? https://isocpp.org/wiki/faq/newbie#floating-point-arith2
To be precise, in the following code the parameters xand yare equal; they can be equal to 1.0 or any other value.
x
y
void foo(double x, double y) { double cos_x = cos(x); double cos_y = cos(y); // the behavior might depend on what in here if (cos_x != cos_y) { std::cout << "Huh?!?\n"; // You might end up here when x == y!! } }
Some compiler options? Loop? Any idea?
, : . , , , . , , , cos , cos. :
cos
, cos (x), , tmp. cos (y) ( , ) cos (y) tmp, .. cos (x).
( ..), , cos . , ==.
==