std::ratio_divide

C++
 Language Concepts Utilities library Strings library Containers library Algorithms library Iterators library Numerics library Input/output library Localizations library Regular expressions library (C++11) Atomic operations library (C++11) Thread support library (C++11)

Numerics library
Common mathematical functions
Floating-point environment
Complex numbers
Numeric arrays
Pseudo-random number generation
Compile-time rational arithmetic (C++11)
Generic numeric operations
 iota (C++11)
 accumulate
 inner_product
 partial_sum

Compile time rational arithmetic
 ratio (C++11)
Arithmetic
 ratio_subtract (C++11)
 ratio_multiply (C++11)
 ratio_divide (C++11)
Comparison
 ratio_equal (C++11)
 ratio_not_equal (C++11)
 ratio_less (C++11)
 ratio_less_equal (C++11)
 ratio_greater (C++11)
 ratio_greater_equal (C++11)

 Defined in header template< class R1, class R2 >using ratio_divide = /* unspecified */;

The template alias std::ratio_divide denotes the result of dividing 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 and Denom == R1::den * R2::num.

Member types

 Member type Definition type std::ratio

Member constants

 num [static] constexpr value of type std::intmax_t equal to sign(Num) * sign(Denom) * abs(Num) / gcd(Num, Denom) (public static member constant) den [static] constexpr value of type std::intmax_t equal to abs(Denom) / gcd(Num, Denom) (public static member constant)

Example

```#include <iostream>
#include <ratio>

int main()
{
typedef std::ratio<2, 3> two_third;
typedef std::ratio<1, 6> one_sixth;
typedef std::ratio_divide<two_third, one_sixth> r;
std::cout << "2/3 / 1/6 = " << r::num << '/' << r::den << '\n';
}```

Output:

`2/3 / 1/6 = 4/1`