title: C++ Integer Division to Float
body: <p>My C++ program takes in three integer inputs and does some computations including division. At first, the end result was not a decimal. After searching a little on Stack Overflow (<a href="https://stackoverflow.com/questions/12447325/dividing-two-integers-to-produce-a-float-result">Dividing two integers to produce a float result</a>), I found out that I'm supposed to add a (float), like this:</p>
  
  <pre><code>int a;
  int b;
  float c;
  
  a = 5;
  b = 2;
  
  c = (float)a / b;
  </code></pre>
  
  <p>So I tried that but I ended up with my result being -nan(ind). First off, what does that mean? And second, how do I make my program work?</p>
  
  <p>Here is the math I am trying to do in my program by the way.</p>
  
  <pre><code>int v;
  int e;
  int a;
  float r;
  
  r = ((float)e - v) / ((float)a / 1000);
  </code></pre>
  
  <p><strong>Edit:</strong> Sorry, my mistake. I meant to type 1000 in the second example, not c.</p>