title: C++ Integer overflow problem when casting from double to unsigned int
body: <p>I need to convert time from one format to another in C++ and it must be cross-platform compatible. I have created a structure as my time container. The structure fields must also be <code>unsigned int</code> as specified by legacy code. </p>
  
  <pre><code>struct time{   
  unsigned int timeInteger;   
  unsigned int timeFraction;
  } time1, time2;
  </code></pre>
  
  <p>Mathematically the conversion is as follows:</p>
  
  <p>time2.timeInteger = time1.timeInteger  + 2208988800</p>
  
  <p>time2.timeFraction = (time1.timeFraction * 20e-6) * 2e32</p>
  
  <p>Here is my original code in C++ however when I attempt to write to a binary file, the converted time does not match with the truth data. I think this problem is due to a type casting mistake? This code will compile in VS2008 and will execute.   </p>
  
  <pre><code>void convertTime(){
     time2.timeInteger  = unsigned int(time1.timeInteger + 2209032000);
     time2.timeFraction = unsigned int(double(time1.timeFraction) * double(20e-6)*double(pow(double(2),32)));
  }
  </code></pre>