Created
August 22, 2011 11:45
-
-
Save usagi/1162205 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <boost/format.hpp> | |
#include <boost/lexical_cast.hpp> | |
#include <iostream> | |
#include <chrono> | |
main(){ | |
namespace c = std::chrono; | |
typedef c::duration<double> real64_seconds; | |
typedef c::duration<float> real32_seconds; | |
auto pi = "3.1415926535897932384626433832795028841971"; | |
auto a = real64_seconds(boost::lexical_cast<double>(pi)); | |
auto b = c::duration_cast<real32_seconds>(a); | |
std::cout | |
<< pi << "\n" | |
<< boost::format("%.32f") % a.count() << "\n" | |
<< c::duration_cast<c::milliseconds>(a).count() << "\n" | |
<< c::duration_cast<c::microseconds>(a).count() << "\n" | |
<< c::duration_cast<c::nanoseconds>(a).count() << "\n" | |
<< c::duration_cast<real32_seconds>(a).count() << "\n" | |
<< boost::format("%.32f") % b.count() << "\n" | |
<< c::duration_cast<c::nanoseconds>(b).count() << "\n" | |
; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(result)
3.1415926535897932384626433832795028841971
3.14159265358979311599796346854419
3141
3141592
3141592653
3.14159
3.14159274101257324218750000000000
3141592832