#include <iostream> #include <ratio> int main(int argc, char *argv[]) { std::ratio<1, 3> oneThird;//variable std::cout<<oneThird.num<<"/"<<oneThird.den<<std::endl; typedef std::ratio<2, 4> twoFourth;//variable type std::cout<<twoFourth::num<<"/"<<twoFourth::den<<std::endl; //ratio_add typedef std::ratio_add<decltype(oneThird), twoFourth> sum; std::cout<<sum::num<<"/"<<sum::den<<std::endl; return 0; }
Type | Description |
---|---|
std::nano | 10-9 |
std::micro | 10-6 |
std::milli | 10-3 |
std::centi | 10-2 |
std::deci | 10-1 |
std::kilo | 103 |
std::mega | 106 |
#include <iostream> #include <ratio> int main(int argc, char *argv[]) { //std::milli std::cout<<std::milli::num<<"/"<<std::milli::den<<std::endl; return 0; }