title: What exactly is a type cast in C/C++?
body: <p>What exactly is a type cast in C/C++? How does the compiler check if an explicit typecast is needed (and valid)? Does it compare the space required for an value? If I have for example:</p>
  
  <pre><code>int a;
  double b = 15.0;
  a = (int) b;
  </code></pre>
  
  <p>If I remember correctly a double value requires more space (was it 8 bytes?!) than an integer (4 bytes). And the internal representation of both are completely different (complement on two/mantissa). So what happens internally? The example here is quite straightforward, but in C/C++ there are plentiful typecasts.</p>
  
  <p>How does the compiler know (or the programmer) if I can cast e.g. FOO to BAR?</p>