I'm trying to implement a GetTime helper function. It gets the current time, measured in counts, then gets the number of counts per second of the system, so you can get the current time in seconds with its relation.
But after that, there is some improvement code that i dont really get. Why are the last two statements there?
double GetTime()
{
// Current time value, measured in counts
__int64 timeInCounts;
QueryPerformanceCounter((LARGE_INTEGER *)(&timeInCounts));
// To get the frequency (counts per second) of the performance timer
__int64 countsPerSecond;
QueryPerformanceFrequency((LARGE_INTEGER *)(&countsPerSecond));
double r, r0, r1;
// Get the time in seconds with the following relation
r0 = double ( timeInCounts / countsPerSecond );
// There is some kind of acuracy improvement here
r1 = ( timeInCounts - ((timeInCounts/countsPerSecond)*countsPerSecond))
/ (double)(countsPerSecond);
r = r0 + r1;
return r;
}