title: What happens when I assign a float variable to an int variable in C++?
body: <p>Let me start by saying that I don't know much about Assembly, but this is something that I'm wondering about.</p>
  
  <p>Let's say that I have a code in C++ such as the following:</p>
  
  <pre><code>float f = 34.2;
  int i;
  
  i = f;
  </code></pre>
  
  <p>Now obviously what will happen when this code gets executed is that the value of <code>f</code> (34.2) will be converted to an integer value (34) and assigned to <code>i</code>.</p>
  
  <p>My question is how does this conversion happens, I mean does it happen at runtime, so at runtime there is a code embedded into the executable that goes something like this: <code>f</code> is being assigned to <code>i</code>, now I know that <code>f</code> is a float and <code>i</code> is an integer, so what I should do is convert the bits in the <code>f</code> variable to an integer representation and then assign it to <code>i</code>;</p>
  
  <p>Or what happens is that at compile time the <code>i = f</code> will directly be replaced by code that will convert a float to an integer?</p>