std::ratio_add
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <ratio>
|
||
| template< class R1, class R2 > using ratio_add = /* unspecified */; |
||
La plantilla
std::ratio_add alias denota el resultado de sumar dos fracciones racionales exactos representados por las instancias std::ratio R1 y R2. El resultado de una instancia std::ratio std::ratio<Num, Denom> donde Num == R1::num * R2::den + R2::num * R1::den y Denom == R1::den * R2::den .Original:
The template alias
std::ratio_add denotes the result of adding two exact rational fractions represented by the std::ratio instances R1 and R2. The result a std::ratio instance std::ratio<Num, Denom> where Num == R1::num * R2::den + R2::num * R1::den and Denom == R1::den * R2::den.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[editar] Tipos de miembros
| Miembro de tipo
Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
type
|
std::ratio<num, den> |
[editar] Constantes de miembros
| num [estático] |
constexpr valor de tipo std::intmax_t igual a sign(Num) * sign(Denom) * abs(Num) / gcd(Num, Denom) Original: The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (público miembro constante estática) |
| den [estático] |
constexpr valor de tipo std::intmax_t igual a abs(Denom) / gcd(Num, Denom) Original: The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (público miembro constante estática) |
[editar] Ejemplo
#include <iostream> #include <ratio> int main() { typedef std::ratio<2, 3> two_third; typedef std::ratio<1, 6> one_sixth; typedef std::ratio_add<two_third, one_sixth> sum; std::cout << "2/3 + 1/6 = " << sum::num << '/' << sum::den << '\n'; }
Output:
2/3 + 1/6 = 5/6

