title: Value changing when converting from double to int
body: <p>Basic question, the code is very large, but my issue is, at it's core, basic :</p>
  
  <p>I have a double value known as variable, and if I check it with cout &lt;&lt; variable, it will give me, for example, 982.</p>
  
  <p>The very next line of code is int intvariable = variable.</p>
  
  <p>Then, when I check it with cout &lt;&lt; intvariable, I'm given 981.</p>
  
  <p>The funny thing is, this doesn't always happen. With 985 it might stay at 985, but then at 984 and 983, it will return 983 and 982. I can't seem to figure this out at ALL. I've tried converting it to a float and then to an int, or to another double and then an int.</p>
  
  <p>I need it as an int so I can use the modulus operator with it.</p>
  
  <p>I should point out, previously in the code the double is less than 1 (i.e, 0.987), and is then multiplied by the number of decimal places to make it a real, positive integer (though, it's stored as a double still at that point). Maybe that has something to do with the random rounding?</p>