std::ratio_subtract
cppreference.com
[] |
Google. . , . , . |
<metanoindex/>
<tbody> </tbody> template< class R1, class R2 > using ratio_subtract = /* unspecified */; |
||
std::ratio_subtract std::ratio R1 R2. std::ratio std::ratio<Num, Denom> Num == R1::num * R2::den - R2::num * R1::den Denom == R1::den * R2::den.:
The template alias
std::ratio_subtract denotes the result of subtracting 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.-
type
|
std::ratio<num, den>
|
num [static] |
(public static -) |
den [static] |
(public static -) |
#include <iostream>
#include <ratio>
int main()
{
typedef std::ratio<2, 3> two_third;
typedef std::ratio<1, 6> one_sixth;
typedef std::ratio_subtract<two_third, one_sixth> diff;
std::cout << "2/3 - 1/6 = " << diff::num << '/' << diff::den << '\n';
}
:
2/3 - 1/6 = 1/2