title: Dividing LONG by INT and assigning to SHORT - Possible in one case?
body: <p>I'm manually calculating the number of cells in a Windows console. (Yes, I know this information is available from a filled CONSOLE_SCREEN_BUFFER_INFO struct.)</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;stdio.h&gt;
  
  int main(void)
  {
      HANDLE hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
      RECT workarea;
      COORD c;
  
      SystemParametersInfoW(SPI_GETWORKAREA, 0, &amp;workarea, 0);
      printf("Rectangle: %ld x %ld\n", workarea.right, workarea.bottom);
      c.X = workarea.right / 8;
      c.Y = workarea.bottom / 12;
      printf("Cells: %d x %d\n", c.X, c.Y);
  
      return 0;
  }
  </code></pre>
  
  <p>The <code>RECT workarea</code> is a structure containing four long integers.  The <code>COORD c</code> is a structure with two short integers.</p>
  
  <p>When dividing a long integer by an integer (e.g. 8 or 12, as above), is there a problem assigning the resulting constant to a short integer? Visual Studio 2012 produces a compile-time warning as would be expected.</p>
  
  <p>But in testing this particular case, <code>SystemParametersInfoW(SPI_GETWORKAREA, 0, &amp;workarea, 0)</code> only gives <code>RECT workarea</code> the resolution of my desktop minus the taskbar height (e.g. 1680 x 1010 pixels).</p>
  
  <p>These numbers are, of course, well within the short integer range.  So, I suppose the question is: is there a potential for data loss in this particular case?</p>