TITLE: Floating point equality PROBLEM: smyth@Jpl.Nasa.Gov (Mike M. Smyth) I have a question for language lawyers. Is it required that the following code double y=some_value; double x=y; if(x ==y) cout<<"TRUE"; always prints TRUE? I realize of course that I can do the test fabs(x-y) T abs(const T& a) {return (a<0) ? -a : a;} //--------------------------------------------- // Name // Feq // // Description // Used to test two floating point numbers to see if // they are close enough to be considered equal. The // usual espsilon is 1e-6 // int Feq(double a, double b, double e) { int retval; if (a == 0 && abs(b) < e) retval = 1; else if (b == 0 && abs(a) < e) retval = 1; else { retval = (abs((a-b)) < (e * abs(a))); } return retval; } int Fle(double a, double b, double e) { return ( (ab) || Feq(a,b,e)); } -------------------------------------------------------------------