10 template<
int64 Num,
int64 Den = 1>
15 template<
class rhs>
struct lessImpl;
18 static_assert(Den != 0,
"Denominator can't be 0");
29 static const int64 n = num * (rhs::den / gcd1) + rhs::num * (den / gcd1);
33 typedef Ratio<n / gcd2, (den / gcd2) * (rhs::den / gcd1)>
type;
48 typedef Ratio<(num / gcd1) * (rhs::num / gcd2), (den / gcd2) * (rhs::den / gcd1)>
type;
80 template<
class lhs,
class rhs>
struct lessCmpFrac;
84 int64 q2 = rhs::num / rhs::den,
92 struct lessCmpSign : lessCmpWhole<rhs> {};
100 struct lessCmpSign<rhs, false, true> :
101 Ratio<-rhs::num, rhs::den>::
102 template lessCmpWhole<
107 template<
class rhs>
struct lessImpl : lessCmpSign<rhs> {};
110 template<
class rhs,
int64 q1,
int64 q2,
bool eq>
111 struct lessCmpWhole :
113 Ratio<num % den, den>,
114 Ratio<rhs::num % rhs::den, rhs::den>
118 template<
class rhs,
int64 q1,
int64 q2>
119 struct lessCmpWhole<rhs, q1, q2, false> :
mt::Value<bool, (q1 < q2)> {};
122 template<class lhs, class rhs>
124 Ratio<rhs::den, rhs::num>::
125 template lessCmpWhole<
126 Ratio<lhs::den, lhs::num>
130 template<class lhs, int64 Den2>
131 struct lessCmpFrac<lhs, Ratio<0, Den2>> : mt::Value<bool, false> {};
134 template<int64 Den1, class rhs>
135 struct lessCmpFrac<Ratio<0, Den1>, rhs> : mt::Value<bool, true> {};
138 template<int64 Den1, int64 Den2>
139 struct lessCmpFrac<Ratio<0, Den1>, Ratio<0, Den2>> : mt::Value<bool, false> {};
145 typedef Ratio<1, 1000000000000000000> Atto;
146 typedef Ratio<1, 1000000000000000> Femto;
147 typedef Ratio<1, 1000000000000> Pico;
148 typedef Ratio<1, 1000000000> Nano;
149 typedef Ratio<1, 1000000> Micro;
150 typedef Ratio<1, 1000> Milli;
151 typedef Ratio<1, 100> Centi;
152 typedef Ratio<1, 10> Deci;
153 typedef Ratio<1, 1> Unit;
154 typedef Ratio<10, 1> Deca;
155 typedef Ratio<100, 1> Hecto;
156 typedef Ratio<1000, 1> Kilo;
157 typedef Ratio<1000000, 1> Mega;
158 typedef Ratio<1000000000, 1> Giga;
159 typedef Ratio<1000000000000, 1> Tera;
160 typedef Ratio<1000000000000000, 1> Peta;
161 typedef Ratio<1000000000000000000, 1> Exa;
170 template<honey::int64 Num, honey::int64 Den, honey::int64 Num2, honey::int64 Den2>
171 struct common_type<honey::Ratio<Num,Den>, honey::Ratio<Num2,Den2>>
174 static const honey::int64 gcdNum = honey::mt::gcd<Num, Num2>::value;
175 static const honey::int64 gcdDen = honey::mt::gcd<Den, Den2>::value;
177 typedef honey::Ratio<gcdNum, (Den / gcdDen) * Den2> type;
mul< Ratio< rhs::den, rhs::num > >::type type
Definition: Ratio.h:53
operator*
Definition: Ratio.h:42
Class to hold compile-time finite rational numbers, ie. the fraction num / den.
Definition: Ratio.h:11
Ratio<(num/gcd1)*(rhs::num/gcd2),(den/gcd2)*(rhs::den/gcd1)> type
Definition: Ratio.h:48
operator/
Definition: Ratio.h:53
static const int64 num
Definition: Ratio.h:20
static const int64 den
Definition: Ratio.h:21
operator<
Definition: Ratio.h:65
Ratio< n/gcd2,(den/gcd2)*(rhs::den/gcd1)> type
Definition: Ratio.h:33
add< Ratio<-rhs::num, rhs::den > >::type type
Definition: Ratio.h:38
operator-
Definition: Ratio.h:38
operator==
Definition: Ratio.h:57
operator+
Definition: Ratio.h:25
operator>=
Definition: Ratio.h:77
Calc greatest common divisor of a and b.
Definition: Meta.h:316
friend struct Ratio
Definition: Ratio.h:14
operator<=
Definition: Ratio.h:69
long long int64
Definition: Core.h:21
operator>
Definition: Ratio.h:73
operator!=
Definition: Ratio.h:61
Global Honeycomb namespace.