cpp/numeric/ratio/ratio

The class template provides compile-time rational arithmetic support. Each instantiation of this template exactly represents any finite rational number as long as its numerator and denominator  are representable as compile-time constants of type std. In addition, may not be zero and both  and  may not be equal to the most negative value.

The static data members and  representing the numerator and denominator are calculated by dividing  and  by their greatest common divisor. However, two with different  or  are distinct types even if they represent the same rational number (after reduction). A type can be reduced to the lowest terms via its  member:  is.

Several convenience typedefs that correspond to the SI ratios are provided by the standard library: