title: Type casting: double to char: multiple questions
body: <p>Consider this code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void) 
  {
      /* TEST 1 */
      double d = 128;
      char ch = (char)d;
      printf(&quot;%d\n&quot;, ch);
  
      /* TEST 2 */
      printf(&quot;%d\n&quot;, (char)128.0);
  
      /* TEST 3 */
      char ch1 = (char)128.0;
      printf(&quot;%d\n&quot;, ch1);
      return 0;
  }
  </code></pre>
  <p>Results:</p>
  <pre><code>        gcc*  clang*  cl*
  TEST 1  -128  -128    -128
  TEST 2  127   0       -128
  TEST 3  127   -2      -128
  
  * latest version
  </code></pre>
  <p>Questions:</p>
  <ol>
  <li>Why the results differ between tests (excluding <code>cl</code>)?</li>
  <li>Why the results differ between compilers (excluding <code>TEST 1</code>)?</li>
  <li>In case of UB/IB, where is the UB/IB exactly? What the standard says?</li>
  <li>[Extra question] Why <code>clang</code> shows so different behavior? Where these <code>0</code> and <code>-2</code> come from?</li>
  </ol>