提高微秒
Boost Microseconds
本文关键字:高微秒 更新时间:2023-10-16
我正在做以下事情
using namespace boost::posix_time;
ptime epoch = time_from_string("1970-01-01 00:00:00.000");
ptime other = time_from_string("2011-08-09 17:27:00.000.000");
time_duration const diff = other - epoch;
long long ms = diff.total_microseconds();
cout<<"diff is"<<ms<<endl;
我得到的回显是差值为1312910820000000
然后当我把ptime other改成
ptime other = time_from_string("2011-08-09 17:27:00.000.100");
我得到相同的回显,为什么?
格式不正确,您有太多的.
分隔符:Live On Coliru
#include <iostream>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/posix_time/posix_time_io.hpp>
int main()
{
using namespace boost::posix_time;
ptime epoch = from_time_t(0);
ptime other = time_from_string("2011-08-09 17:27:00.000000");
std::cout << "diff is " << (other - epoch).total_microseconds() << std::endl;
other = time_from_string("2011-08-09 17:27:00.00001");
std::cout << "diff is " << (other - epoch).total_microseconds() << std::endl;
}
打印
diff is 1312910820000000
diff is 1312910820000010
相关文章:
- 计算每个节点的树高,帮助我解释这个代码解决方案
- 当使用比格式支持的精度更高的精度来显示数字时,会写出什么数据
- C++高阶模板
- 获取 SFML 窗口的 HWND 和高可用性?
- Opencv 恢复到比我设置的更高的分辨率
- 输入较高值时的分段代码
- 高精度双精度的 Sprintf 格式化问题
- 用于测量微秒的QueryPerformanceCounter的奇怪行为
- 在Windows(C++)中使用USB相机拍摄高分辨率照片
- 较高值 n 的分割错误(例如 n=999997)
- 在 C++11 及更高版本中,有没有办法初始化初始值设定项列表中的向量?
- 将更高的优先级设置为 boost::asio 线程处理进程
- 在C++上实现高斯赛德尔迭代方法
- 我的 c++ 应用程序中的运行时间从 0 增加到 60 太快了(例如一毫秒或一微秒)
- 如何在C++中为高分辨率时钟声明变量?
- 窗口中的微秒计时器
- 在 Windows/C++ 上使用多进程应用程序的高精度定时操作
- 为什么 Perf 具有如此高的上下文切换?
- 如何获得CMake Tools以在Visual Studio Code中编译具有C++11(或更高版本)功能的程序?
- C++:矩阵高斯消除不起作用:使用单维数组来存储元素