// P. Conrad  badFloat.cc  for CISC106 sect 99  11/06/2006
// illustration of problems with comparing floating point numbers


#include <iostream>
#include <iomanip> // for setprecision() ?? 
using namespace std;

int main() 
{
 

  float number = 1.80;
  float calculation = number * 1.1; // 1.8 + 10% of 1.8

  float expectedanswer = 1.98;   //as we know, 1.8 + 10% of 1.8 = 1.98

  cout <<"Comparing " << calculation <<" and " << expectedanswer << endl;
  
  cout << setprecision(20) 
       << "Comparing (with setprecision(20) "
       << calculation <<" and " << expectedanswer << endl;
   
  if ( calculation == expectedanswer )
    {
      cout <<"Equal!" <<endl;
    }
    else 
      {
	cout <<"Not Equal!" <<endl;
      }
  cout <<endl;
}











