Consider following piece of code:
#include <iostream>
using namespace std;
int main() {
double x = 1.77;
double y = 1.76;
double diff = x-y;
cout << "x-y = " << diff << endl;
if (diff <= 0.01)
{
cout << "x and y differ by less than 1.0/100 ..." << endl;
}
return 0;
}
Following output I am getting:
x-y = 0.01
But I don't see the print x and y differ by less than 1.0/100...
which is expected here because difference between x
and y
is 0.01
.