<ratio>

Incluya el encabezado estándar <ratio> para definir constantes y las plantillas que se utilizan para almacenar y manipular los números racionales en tiempo de compilación.

#include <ratio>

Hh874762.collapse_all(es-es,VS.110).gifestructura de la relación

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 define las constantes estáticas num y den tales que num /n/d == de den y num y den no tiene ningún factor común.num / den es value representado por la clase de plantilla.Por consiguiente, type designa la creación ratio<N0, D0> que == N0 de num y == D0 de den .

Hh874762.collapse_all(es-es,VS.110).gifespecializaciones

<ratio> también define las especializaciones de ratio con el formato siguiente.

template <class R1, class R2> struct ratio_specialization

Cada especialización toma dos parámetros de plantilla que deben ser especializaciones de ratio.El valor de type está determinado por una operación lógica asociada.

Name

Valor de type

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(es-es,VS.110).giftypedefs

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;

Vea también

Otros recursos

Archivos de encabezado