Aracılığıyla paylaş


<ratio>

<ratio> Standart başlığı dahil et sabitler ve depolamak ve rasyonel sayılar derleme zamanında işlemek için kullanılan şablonları tanımlamak için.

#include <ratio>

Hh874762.collapse_all(tr-tr,VS.110).giforanı yapı

template <intmax_t N, intmax_t D = 1>
struct ratio
{
    static constexpr intmax_t num;
    static constexpr intmax_t den;
    typedef ratio<num, den> type;
};

ratio Structure Statik sabitleri tanımlar num ve den , num / den == n / d ve num ve den hiçbir ortak Etkenler vardır.num/ den olan value şablon sınıfı tarafından temsil.Bu nedenle, type oluşturmada atar ratio<N0, D0> , num == N0 ve den D0 ==.

Hh874762.collapse_all(tr-tr,VS.110).gifSpecializations

<ratio> Ayrıca, specializations tanımlar ratio aşağıdaki biçime sahip.

template <class R1, class R2> struct ratio_specialization

Her uzmanlığı da specializations biri olmalıdır iki şablon parametreleri alır ratio.Değeri type bir ilişkili mantıksal işlem tarafından belirlenir.

Ad

typeDeğer

ratio_add

R1 + R2

ratio_divide

R1 / R2

ratio_equal

R1 == R2

ratio_greater

R1 > R2

ratio_greater_equal

R1 >= R2

ratio_less

R1 < R2

ratio_less_equal

R1 <= R2

ratio_multiply

R1 * R2

ratio_not_equal

!(R1 == R2)

ratio_subtract

R1 - R2

Hh874762.collapse_all(tr-tr,VS.110).gifTypeDef

typedef ratio<1,        1000000000000000000> atto;
typedef ratio<1,           1000000000000000> femto;
typedef ratio<1,              1000000000000> pico;
typedef ratio<1,                 1000000000> nano;
typedef ratio<1,                    1000000> micro;
typedef ratio<1,                       1000> milli;
typedef ratio<1,                        100> centi;
typedef ratio<1,                         10> deci;
typedef ratio<                        10, 1> deca;
typedef ratio<                       100, 1> hecto;
typedef ratio<                      1000, 1> kilo;
typedef ratio<                   1000000, 1> mega;
typedef ratio<                1000000000, 1> giga;
typedef ratio<             1000000000000, 1> tera;
typedef ratio<          1000000000000000, 1> peta;
typedef ratio<       1000000000000000000, 1> exa;

Ayrıca bkz.

Diğer Kaynaklar

Üstbilgi dosyaları