Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++中的64次时间计算 FILETIME ftTime; GetSystemTimeAsFileTime(&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*)&myTime; // I have Getstring format from date time some thing like this below Format() { SYSTEMTIME systemTime; FileTimeToSystemTime(&fileTime, &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 << "\nOn Start Time:" << startTime.Format() << std::endl; std::cout << "On End Tme: " << endTime.Format() << std::endl; std::cout << "On Start Read " << *(unsigned __int64*)&startTime << std::endl; std::cout << "On End Read " << *(unsigned __int64*)&endtime<< std::endl; ///////////////////_C++ - Fatal编程技术网

C++中的64次时间计算 FILETIME ftTime; GetSystemTimeAsFileTime(&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*)&myTime; // I have Getstring format from date time some thing like this below Format() { SYSTEMTIME systemTime; FileTimeToSystemTime(&fileTime, &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 << "\nOn Start Time:" << startTime.Format() << std::endl; std::cout << "On End Tme: " << endTime.Format() << std::endl; std::cout << "On Start Read " << *(unsigned __int64*)&startTime << std::endl; std::cout << "On End Read " << *(unsigned __int64*)&endtime<< std::endl; ///////////////////

C++中的64次时间计算 FILETIME ftTime; GetSystemTimeAsFileTime(&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*)&myTime; // I have Getstring format from date time some thing like this below Format() { SYSTEMTIME systemTime; FileTimeToSystemTime(&fileTime, &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 << "\nOn Start Time:" << startTime.Format() << std::endl; std::cout << "On End Tme: " << endTime.Format() << std::endl; std::cout << "On Start Read " << *(unsigned __int64*)&startTime << std::endl; std::cout << "On End Read " << *(unsigned __int64*)&endtime<< std::endl; ///////////////////,c++,C++,我的问题是,我想根据给定的间隔,将边界划分为相等的间隔,例如每间隔2秒。我该怎么做 上限范围/间隔 例如,开始时间:12:00:00:0000,结束时间为12:01:52:00099。间隔是16秒,然后我们有7个间隔 unsigned __int64 interval =16; 如果我在上面使用int逻辑,如果我使用*unsigned\uu int64*&endtime-*unsigned\uu int64*&startTime/interval,我不会得到7?如何修复它?FILETIME结构

我的问题是,我想根据给定的间隔,将边界划分为相等的间隔,例如每间隔2秒。我该怎么做

上限范围/间隔

例如,开始时间:12:00:00:0000,结束时间为12:01:52:00099。间隔是16秒,然后我们有7个间隔

unsigned __int64 interval =16;
如果我在上面使用int逻辑,如果我使用*unsigned\uu int64*&endtime-*unsigned\uu int64*&startTime/interval,我不会得到7?如何修复它?

FILETIME结构包含一个64位值,表示自1601年1月1日UTC以来的100纳秒间隔数

检查此链接:

因此,对两个FILETIME变量进行减法运算可以得到以纳秒为单位的时间差

除以16秒不会得到你想要的


除以16*10^9或使用difftime API为您执行此计算并以秒为单位返回时间差

您是否已经考虑过difftime API。这使得时间及其差异的实现更加容易。好的,starttime和endtime是文件时间,是100纳秒的倍数。看起来你假设它们是秒?
unsigned __int64 interval =16;