title: Subtraction of Double type Values in C++
body: <p>I am trying to subtract a small double number from a large double number in C++. Here is my code</p>
  
  <pre><code>int main() 
  {
  double a=166666166667000000.000000;
  double b=1.0;
  double c=4.0;
  double d=10.0;
  
  double ans_b=a-b;
  double ans_c=a-c;
  double ans_d=a-d;
  
  printf("%f\n%f\n%f\n",ans_b,ans_c,ans_d);
  return 0;
  }
  </code></pre>
  
  <p>This Code is giving me following output - </p>
  
  <pre><code>166666166667000000.000000
  166666166667000000.000000
  166666166667000000.000000
  </code></pre>
  
  <p>However, all three are supposed to be different. Why does subtraction with double type behaves this way?</p>