2013-04-18 23 views

回答

6

boost::posix_time::microseconds

#include <iostream> 
#include <boost/date_time.hpp> 
namespace bpt = boost::posix_time; 
int main() 
{ 
    bpt::time_duration td = bpt::microseconds(12345678); 
    std::cout << td << '\n'; 
} 
+0

嗯...我試過了。我輸入數字「34200186270」,根據我的計算,這個數字應該是大約9點30分,但是,當我輸出00:35:47.483647的結果時, – Craig 2013-04-18 03:12:48

+0

編輯:等待那一個,當我將它提供給你的測試程序時,我得到了正確的編號,必須是某處的代碼錯誤。感謝您的幫助。 – Craig 2013-04-18 03:15:59

+1

@克雷格我得到了'09:30:00.186270'。你的持續時間是2^31微秒,也許你把它存儲在32位有符號數的地方? – Cubbi 2013-04-18 03:16:51

相關問題