// con1.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include using namespace std; int main() { float x = 0.1; x += 0.1; x += 0.1; x += 0.1; // if (x==0.4) would be wrong due to rounding errors. // fabs(y) |y| needs math.h if (fabs(x - 0.4) < 1e-6) cout << "yes" << endl; return 0; }