A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/ratio/ratio_divide/ below:

class template

<ratio>

std::ratio_divide
template <class R1, class R2> ratio_divide;

Divide ratios

This class template alias generates a ratio type that is the result of dividing the ratio type R1 by the ratio type R2.

The resulting type is the same as if ratio_divide was defined as:


1
2
template <typename R1, typename R2>
using ratio_divide = ratio < R1::num * R2::den, R2::num * R1::den >;

A program shall not cause any expression in the above definition to expand to values not representable as an intmax_t.

Template parameters
R1,R2
ratio types to be divided.

Member constants The same as ratio (ratio_divide is merely a template alias).
member constexpr description num Numerator den Denominator
The values of num and den represent the result of the division operation.

Member types The same as ratio (ratio_divide is merely a template alias).
member type definition description type ratio<num,den> The ratio type with the result of the division. Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// ratio_divide example
#include <iostream>
#include <ratio>

int main ()
{
  typedef std::ratio<1,2> one_half;
  typedef std::ratio<1,3> one_third;

  typedef std::ratio_divide<one_half,one_third> result;

  std::cout << "result = " << result::num << "/" << result::den;
  std::cout << " (which is: " << ( double(result::num) / result::den ) << ")" << std::endl;

  return 0;
}

Output:
result = 3/2 (which is: 1.5)


See also
ratio_add
Add two ratios (class template)
ratio_multiply
Multiply two ratios (class template)
ratio_equal
Compare ratios (class template)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4