rational_c
template<
typename IntegerType
, IntegerType N
, IntegerType D = 1
>
struct rational_c
{
typedef rational_c<IntegerType, N, D> type;
typedef IntegerType integer_type;
typedef integral_c<IntegerType,N> numerator;
typedef integral_c<IntegerType,D> denominator;
static double value();
};
A model of Rational Constant.
#include "boost/mpl/math/rational_c.hpp"
| Parameter | Requirement | Description |
|---|---|---|
IntegerType | An integral type | Type used to represent numerator and denominator. |
N | A compile time integral constant of type IntegerType | Value of numerator. |
D | A compile time integral constant of type IntegerType | Value of denominator. |
| Expression | Expression type | Precondition | Semantics | Postcondition |
|---|---|---|---|---|
rational_c<T,n,d>::value() | double | static_cast<T>(d) != 0 | Returns static_cast<double>(static_cast<T>(n)) / static_cast<T>(d). |
All operations take amortized constant time.
typedef rational_c<int,1,2> half; typedef rational_c<int,2,4> half_2; typedef rational_c<long,9,15> three_fiths_3; typedef rational_plus<three_fiths,half>::type eleven_tenth; typedef rational_plus<half,half>::type one; typedef rational_c<long,1,8> eighth; typedef rational_minus<half,eighth>::type three_eighths; typedef rational_multiplies<half,eighth>::type sixteenth; typedef rational_divides<eighth,half>::type quarter;
Rational Constant, Integral Constant, integral_c