int64 time calculations in C++
<p>I am working on timing related code in C++.</p>

<pre><code>FILETIME ftTime;
GetSystemTimeAsFileTime(&amp;ftTime);

struct DateTime
{
    unsigned int dwLowDateTime;
    unsigned int dwHighDateTime;
};



DateTime myTime;
myTime.dwHighDateTime = (unsigned int)ftTime.dwHighDateTime;
myTime.dwLowDateTime  = (unsigned int)ftTime.dwLowDateTime;

ussigned __int64 AsUInt64_t

unsigned __int64 myInt64Time = *(unsigned __int64*)&amp;myTime;

// I have Getstring format from date time some thing like this below

Format() {

SYSTEMTIME  systemTime;
FileTimeToSystemTime(&amp;fileTime, &amp;systemTime);

const char*         formatString = "%04d-%02d-%02d %02d:%02d:%02d.%03d";

// I have few variable declartions to be used for snprintf which is not mentioned here.

apiResult = _snprintf_s(pBuffer, sizeOfBuffer, count, formatString, systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour, systemTime.wMinute,                         systemTime.wSecond, systemTime.wMilliseconds);

}

DateTime startTime = now(); // some how I am getting latest time here.
sleep(5s); // sleeping for 5 seconds.
DateTime endTime = now(); // i.e., after 5 seconds.

std::cout &lt;&lt; "\nOn Start Time:" &lt;&lt; startTime.Format() &lt;&lt; std::endl;
std::cout &lt;&lt; "On End Tme:    " &lt;&lt; endTime.Format() &lt;&lt; std::endl;

std::cout &lt;&lt; "On Start Read " &lt;&lt; *(unsigned __int64*)&amp;startTime &lt;&lt; std::endl;
std::cout &lt;&lt; "On End Read " &lt;&lt; *(unsigned __int64*)&amp;endtime&lt;&lt; std::endl;

///////////////////
</code></pre>

<p>For above output is coming as below.</p>

<pre><code>On Start Time:2012-06-18 09:45:03.180
On End Time  :2012-06-18 09:45:08.183

// Int Int64 I am getting as below

On Start Read : 129844863031802858
On End Read   : 129844863081832935
</code></pre>

<p>My question is I want to divide the bounds in to equal interval according to given interval for example each interval of 2 seconds. How do I go that?</p>

<p>ceiling (Range/Interval) intervals.</p>

<p>For example start: 12:00:00:0000 and end is 12:01:52:00099. Interval is 16 seconds, then we have 7 intervals. </p>

<pre><code>unsigned __int64 interval =16;
</code></pre>

<p>If I use int above logic if I do <code>(*(unsigned __int64*)&amp;endtime - *(unsigned __int64*)&amp;startTime) / interval)</code>, I am not getting 7 ? How do I fix it?</p>
