ratio 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. // ratio -*- C++ -*-
  2. // Copyright (C) 2008-2015 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // Under Section 7 of GPL version 3, you are granted additional
  14. // permissions described in the GCC Runtime Library Exception, version
  15. // 3.1, as published by the Free Software Foundation.
  16. // You should have received a copy of the GNU General Public License and
  17. // a copy of the GCC Runtime Library Exception along with this program;
  18. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. // <http://www.gnu.org/licenses/>.
  20. /** @file include/ratio
  21. * This is a Standard C++ Library header.
  22. */
  23. #ifndef _GLIBCXX_RATIO
  24. #define _GLIBCXX_RATIO 1
  25. #pragma GCC system_header
  26. #if __cplusplus < 201103L
  27. # include <bits/c++0x_warning.h>
  28. #else
  29. #include <type_traits>
  30. #include <cstdint>
  31. #ifdef _GLIBCXX_USE_C99_STDINT_TR1
  32. namespace std _GLIBCXX_VISIBILITY(default)
  33. {
  34. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  35. /**
  36. * @defgroup ratio Rational Arithmetic
  37. * @ingroup utilities
  38. *
  39. * Compile time representation of finite rational numbers.
  40. * @{
  41. */
  42. template<intmax_t _Pn>
  43. struct __static_sign
  44. : integral_constant<intmax_t, (_Pn < 0) ? -1 : 1>
  45. { };
  46. template<intmax_t _Pn>
  47. struct __static_abs
  48. : integral_constant<intmax_t, _Pn * __static_sign<_Pn>::value>
  49. { };
  50. template<intmax_t _Pn, intmax_t _Qn>
  51. struct __static_gcd
  52. : __static_gcd<_Qn, (_Pn % _Qn)>
  53. { };
  54. template<intmax_t _Pn>
  55. struct __static_gcd<_Pn, 0>
  56. : integral_constant<intmax_t, __static_abs<_Pn>::value>
  57. { };
  58. template<intmax_t _Qn>
  59. struct __static_gcd<0, _Qn>
  60. : integral_constant<intmax_t, __static_abs<_Qn>::value>
  61. { };
  62. // Let c = 2^(half # of bits in an intmax_t)
  63. // then we find a1, a0, b1, b0 s.t. N = a1*c + a0, M = b1*c + b0
  64. // The multiplication of N and M becomes,
  65. // N * M = (a1 * b1)c^2 + (a0 * b1 + b0 * a1)c + a0 * b0
  66. // Multiplication is safe if each term and the sum of the terms
  67. // is representable by intmax_t.
  68. template<intmax_t _Pn, intmax_t _Qn>
  69. struct __safe_multiply
  70. {
  71. private:
  72. static const uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4);
  73. static const uintmax_t __a0 = __static_abs<_Pn>::value % __c;
  74. static const uintmax_t __a1 = __static_abs<_Pn>::value / __c;
  75. static const uintmax_t __b0 = __static_abs<_Qn>::value % __c;
  76. static const uintmax_t __b1 = __static_abs<_Qn>::value / __c;
  77. static_assert(__a1 == 0 || __b1 == 0,
  78. "overflow in multiplication");
  79. static_assert(__a0 * __b1 + __b0 * __a1 < (__c >> 1),
  80. "overflow in multiplication");
  81. static_assert(__b0 * __a0 <= __INTMAX_MAX__,
  82. "overflow in multiplication");
  83. static_assert((__a0 * __b1 + __b0 * __a1) * __c
  84. <= __INTMAX_MAX__ - __b0 * __a0,
  85. "overflow in multiplication");
  86. public:
  87. static const intmax_t value = _Pn * _Qn;
  88. };
  89. // Some double-precision utilities, where numbers are represented as
  90. // __hi*2^(8*sizeof(uintmax_t)) + __lo.
  91. template<uintmax_t __hi1, uintmax_t __lo1, uintmax_t __hi2, uintmax_t __lo2>
  92. struct __big_less
  93. : integral_constant<bool, (__hi1 < __hi2
  94. || (__hi1 == __hi2 && __lo1 < __lo2))>
  95. { };
  96. template<uintmax_t __hi1, uintmax_t __lo1, uintmax_t __hi2, uintmax_t __lo2>
  97. struct __big_add
  98. {
  99. static constexpr uintmax_t __lo = __lo1 + __lo2;
  100. static constexpr uintmax_t __hi = (__hi1 + __hi2 +
  101. (__lo1 + __lo2 < __lo1)); // carry
  102. };
  103. // Subtract a number from a bigger one.
  104. template<uintmax_t __hi1, uintmax_t __lo1, uintmax_t __hi2, uintmax_t __lo2>
  105. struct __big_sub
  106. {
  107. static_assert(!__big_less<__hi1, __lo1, __hi2, __lo2>::value,
  108. "Internal library error");
  109. static constexpr uintmax_t __lo = __lo1 - __lo2;
  110. static constexpr uintmax_t __hi = (__hi1 - __hi2 -
  111. (__lo1 < __lo2)); // carry
  112. };
  113. // Same principle as __safe_multiply.
  114. template<uintmax_t __x, uintmax_t __y>
  115. struct __big_mul
  116. {
  117. private:
  118. static constexpr uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4);
  119. static constexpr uintmax_t __x0 = __x % __c;
  120. static constexpr uintmax_t __x1 = __x / __c;
  121. static constexpr uintmax_t __y0 = __y % __c;
  122. static constexpr uintmax_t __y1 = __y / __c;
  123. static constexpr uintmax_t __x0y0 = __x0 * __y0;
  124. static constexpr uintmax_t __x0y1 = __x0 * __y1;
  125. static constexpr uintmax_t __x1y0 = __x1 * __y0;
  126. static constexpr uintmax_t __x1y1 = __x1 * __y1;
  127. static constexpr uintmax_t __mix = __x0y1 + __x1y0; // possible carry...
  128. static constexpr uintmax_t __mix_lo = __mix * __c;
  129. static constexpr uintmax_t __mix_hi
  130. = __mix / __c + ((__mix < __x0y1) ? __c : 0); // ... added here
  131. typedef __big_add<__mix_hi, __mix_lo, __x1y1, __x0y0> _Res;
  132. public:
  133. static constexpr uintmax_t __hi = _Res::__hi;
  134. static constexpr uintmax_t __lo = _Res::__lo;
  135. };
  136. // Adapted from __udiv_qrnnd_c in longlong.h
  137. // This version assumes that the high bit of __d is 1.
  138. template<uintmax_t __n1, uintmax_t __n0, uintmax_t __d>
  139. struct __big_div_impl
  140. {
  141. private:
  142. static_assert(__d >= (uintmax_t(1) << (sizeof(intmax_t) * 8 - 1)),
  143. "Internal library error");
  144. static_assert(__n1 < __d, "Internal library error");
  145. static constexpr uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4);
  146. static constexpr uintmax_t __d1 = __d / __c;
  147. static constexpr uintmax_t __d0 = __d % __c;
  148. static constexpr uintmax_t __q1x = __n1 / __d1;
  149. static constexpr uintmax_t __r1x = __n1 % __d1;
  150. static constexpr uintmax_t __m = __q1x * __d0;
  151. static constexpr uintmax_t __r1y = __r1x * __c + __n0 / __c;
  152. static constexpr uintmax_t __r1z = __r1y + __d;
  153. static constexpr uintmax_t __r1
  154. = ((__r1y < __m) ? ((__r1z >= __d) && (__r1z < __m))
  155. ? (__r1z + __d) : __r1z : __r1y) - __m;
  156. static constexpr uintmax_t __q1
  157. = __q1x - ((__r1y < __m)
  158. ? ((__r1z >= __d) && (__r1z < __m)) ? 2 : 1 : 0);
  159. static constexpr uintmax_t __q0x = __r1 / __d1;
  160. static constexpr uintmax_t __r0x = __r1 % __d1;
  161. static constexpr uintmax_t __n = __q0x * __d0;
  162. static constexpr uintmax_t __r0y = __r0x * __c + __n0 % __c;
  163. static constexpr uintmax_t __r0z = __r0y + __d;
  164. static constexpr uintmax_t __r0
  165. = ((__r0y < __n) ? ((__r0z >= __d) && (__r0z < __n))
  166. ? (__r0z + __d) : __r0z : __r0y) - __n;
  167. static constexpr uintmax_t __q0
  168. = __q0x - ((__r0y < __n) ? ((__r0z >= __d)
  169. && (__r0z < __n)) ? 2 : 1 : 0);
  170. public:
  171. static constexpr uintmax_t __quot = __q1 * __c + __q0;
  172. static constexpr uintmax_t __rem = __r0;
  173. private:
  174. typedef __big_mul<__quot, __d> _Prod;
  175. typedef __big_add<_Prod::__hi, _Prod::__lo, 0, __rem> _Sum;
  176. static_assert(_Sum::__hi == __n1 && _Sum::__lo == __n0,
  177. "Internal library error");
  178. };
  179. template<uintmax_t __n1, uintmax_t __n0, uintmax_t __d>
  180. struct __big_div
  181. {
  182. private:
  183. static_assert(__d != 0, "Internal library error");
  184. static_assert(sizeof (uintmax_t) == sizeof (unsigned long long),
  185. "This library calls __builtin_clzll on uintmax_t, which "
  186. "is unsafe on your platform. Please complain to "
  187. "http://gcc.gnu.org/bugzilla/");
  188. static constexpr int __shift = __builtin_clzll(__d);
  189. static constexpr int __coshift_ = sizeof(uintmax_t) * 8 - __shift;
  190. static constexpr int __coshift = (__shift != 0) ? __coshift_ : 0;
  191. static constexpr uintmax_t __c1 = uintmax_t(1) << __shift;
  192. static constexpr uintmax_t __c2 = uintmax_t(1) << __coshift;
  193. static constexpr uintmax_t __new_d = __d * __c1;
  194. static constexpr uintmax_t __new_n0 = __n0 * __c1;
  195. static constexpr uintmax_t __n1_shifted = (__n1 % __d) * __c1;
  196. static constexpr uintmax_t __n0_top = (__shift != 0) ? (__n0 / __c2) : 0;
  197. static constexpr uintmax_t __new_n1 = __n1_shifted + __n0_top;
  198. typedef __big_div_impl<__new_n1, __new_n0, __new_d> _Res;
  199. public:
  200. static constexpr uintmax_t __quot_hi = __n1 / __d;
  201. static constexpr uintmax_t __quot_lo = _Res::__quot;
  202. static constexpr uintmax_t __rem = _Res::__rem / __c1;
  203. private:
  204. typedef __big_mul<__quot_lo, __d> _P0;
  205. typedef __big_mul<__quot_hi, __d> _P1;
  206. typedef __big_add<_P0::__hi, _P0::__lo, _P1::__lo, __rem> _Sum;
  207. // No overflow.
  208. static_assert(_P1::__hi == 0, "Internal library error");
  209. static_assert(_Sum::__hi >= _P0::__hi, "Internal library error");
  210. // Matches the input data.
  211. static_assert(_Sum::__hi == __n1 && _Sum::__lo == __n0,
  212. "Internal library error");
  213. static_assert(__rem < __d, "Internal library error");
  214. };
  215. /**
  216. * @brief Provides compile-time rational arithmetic.
  217. *
  218. * This class template represents any finite rational number with a
  219. * numerator and denominator representable by compile-time constants of
  220. * type intmax_t. The ratio is simplified when instantiated.
  221. *
  222. * For example:
  223. * @code
  224. * std::ratio<7,-21>::num == -1;
  225. * std::ratio<7,-21>::den == 3;
  226. * @endcode
  227. *
  228. */
  229. template<intmax_t _Num, intmax_t _Den = 1>
  230. struct ratio
  231. {
  232. static_assert(_Den != 0, "denominator cannot be zero");
  233. static_assert(_Num >= -__INTMAX_MAX__ && _Den >= -__INTMAX_MAX__,
  234. "out of range");
  235. // Note: sign(N) * abs(N) == N
  236. static constexpr intmax_t num =
  237. _Num * __static_sign<_Den>::value / __static_gcd<_Num, _Den>::value;
  238. static constexpr intmax_t den =
  239. __static_abs<_Den>::value / __static_gcd<_Num, _Den>::value;
  240. typedef ratio<num, den> type;
  241. };
  242. template<intmax_t _Num, intmax_t _Den>
  243. constexpr intmax_t ratio<_Num, _Den>::num;
  244. template<intmax_t _Num, intmax_t _Den>
  245. constexpr intmax_t ratio<_Num, _Den>::den;
  246. template<typename _R1, typename _R2>
  247. struct __ratio_multiply
  248. {
  249. private:
  250. static const intmax_t __gcd1 =
  251. __static_gcd<_R1::num, _R2::den>::value;
  252. static const intmax_t __gcd2 =
  253. __static_gcd<_R2::num, _R1::den>::value;
  254. public:
  255. typedef ratio<
  256. __safe_multiply<(_R1::num / __gcd1),
  257. (_R2::num / __gcd2)>::value,
  258. __safe_multiply<(_R1::den / __gcd2),
  259. (_R2::den / __gcd1)>::value> type;
  260. static constexpr intmax_t num = type::num;
  261. static constexpr intmax_t den = type::den;
  262. };
  263. template<typename _R1, typename _R2>
  264. constexpr intmax_t __ratio_multiply<_R1, _R2>::num;
  265. template<typename _R1, typename _R2>
  266. constexpr intmax_t __ratio_multiply<_R1, _R2>::den;
  267. /// ratio_multiply
  268. template<typename _R1, typename _R2>
  269. using ratio_multiply = typename __ratio_multiply<_R1, _R2>::type;
  270. template<typename _R1, typename _R2>
  271. struct __ratio_divide
  272. {
  273. static_assert(_R2::num != 0, "division by 0");
  274. typedef typename __ratio_multiply<
  275. _R1,
  276. ratio<_R2::den, _R2::num>>::type type;
  277. static constexpr intmax_t num = type::num;
  278. static constexpr intmax_t den = type::den;
  279. };
  280. template<typename _R1, typename _R2>
  281. constexpr intmax_t __ratio_divide<_R1, _R2>::num;
  282. template<typename _R1, typename _R2>
  283. constexpr intmax_t __ratio_divide<_R1, _R2>::den;
  284. /// ratio_divide
  285. template<typename _R1, typename _R2>
  286. using ratio_divide = typename __ratio_divide<_R1, _R2>::type;
  287. /// ratio_equal
  288. template<typename _R1, typename _R2>
  289. struct ratio_equal
  290. : integral_constant<bool, _R1::num == _R2::num && _R1::den == _R2::den>
  291. { };
  292. /// ratio_not_equal
  293. template<typename _R1, typename _R2>
  294. struct ratio_not_equal
  295. : integral_constant<bool, !ratio_equal<_R1, _R2>::value>
  296. { };
  297. // Both numbers are positive.
  298. template<typename _R1, typename _R2,
  299. typename _Left = __big_mul<_R1::num,_R2::den>,
  300. typename _Right = __big_mul<_R2::num,_R1::den> >
  301. struct __ratio_less_impl_1
  302. : integral_constant<bool, __big_less<_Left::__hi, _Left::__lo,
  303. _Right::__hi, _Right::__lo>::value>
  304. { };
  305. template<typename _R1, typename _R2,
  306. bool = (_R1::num == 0 || _R2::num == 0
  307. || (__static_sign<_R1::num>::value
  308. != __static_sign<_R2::num>::value)),
  309. bool = (__static_sign<_R1::num>::value == -1
  310. && __static_sign<_R2::num>::value == -1)>
  311. struct __ratio_less_impl
  312. : __ratio_less_impl_1<_R1, _R2>::type
  313. { };
  314. template<typename _R1, typename _R2>
  315. struct __ratio_less_impl<_R1, _R2, true, false>
  316. : integral_constant<bool, _R1::num < _R2::num>
  317. { };
  318. template<typename _R1, typename _R2>
  319. struct __ratio_less_impl<_R1, _R2, false, true>
  320. : __ratio_less_impl_1<ratio<-_R2::num, _R2::den>,
  321. ratio<-_R1::num, _R1::den> >::type
  322. { };
  323. /// ratio_less
  324. template<typename _R1, typename _R2>
  325. struct ratio_less
  326. : __ratio_less_impl<_R1, _R2>::type
  327. { };
  328. /// ratio_less_equal
  329. template<typename _R1, typename _R2>
  330. struct ratio_less_equal
  331. : integral_constant<bool, !ratio_less<_R2, _R1>::value>
  332. { };
  333. /// ratio_greater
  334. template<typename _R1, typename _R2>
  335. struct ratio_greater
  336. : integral_constant<bool, ratio_less<_R2, _R1>::value>
  337. { };
  338. /// ratio_greater_equal
  339. template<typename _R1, typename _R2>
  340. struct ratio_greater_equal
  341. : integral_constant<bool, !ratio_less<_R1, _R2>::value>
  342. { };
  343. template<typename _R1, typename _R2,
  344. bool = (_R1::num >= 0),
  345. bool = (_R2::num >= 0),
  346. bool = ratio_less<ratio<__static_abs<_R1::num>::value, _R1::den>,
  347. ratio<__static_abs<_R2::num>::value, _R2::den> >::value>
  348. struct __ratio_add_impl
  349. {
  350. private:
  351. typedef typename __ratio_add_impl<
  352. ratio<-_R1::num, _R1::den>,
  353. ratio<-_R2::num, _R2::den> >::type __t;
  354. public:
  355. typedef ratio<-__t::num, __t::den> type;
  356. };
  357. // True addition of nonnegative numbers.
  358. template<typename _R1, typename _R2, bool __b>
  359. struct __ratio_add_impl<_R1, _R2, true, true, __b>
  360. {
  361. private:
  362. static constexpr uintmax_t __g = __static_gcd<_R1::den, _R2::den>::value;
  363. static constexpr uintmax_t __d2 = _R2::den / __g;
  364. typedef __big_mul<_R1::den, __d2> __d;
  365. typedef __big_mul<_R1::num, _R2::den / __g> __x;
  366. typedef __big_mul<_R2::num, _R1::den / __g> __y;
  367. typedef __big_add<__x::__hi, __x::__lo, __y::__hi, __y::__lo> __n;
  368. static_assert(__n::__hi >= __x::__hi, "Internal library error");
  369. typedef __big_div<__n::__hi, __n::__lo, __g> __ng;
  370. static constexpr uintmax_t __g2 = __static_gcd<__ng::__rem, __g>::value;
  371. typedef __big_div<__n::__hi, __n::__lo, __g2> __n_final;
  372. static_assert(__n_final::__rem == 0, "Internal library error");
  373. static_assert(__n_final::__quot_hi == 0 &&
  374. __n_final::__quot_lo <= __INTMAX_MAX__, "overflow in addition");
  375. typedef __big_mul<_R1::den / __g2, __d2> __d_final;
  376. static_assert(__d_final::__hi == 0 &&
  377. __d_final::__lo <= __INTMAX_MAX__, "overflow in addition");
  378. public:
  379. typedef ratio<__n_final::__quot_lo, __d_final::__lo> type;
  380. };
  381. template<typename _R1, typename _R2>
  382. struct __ratio_add_impl<_R1, _R2, false, true, true>
  383. : __ratio_add_impl<_R2, _R1>
  384. { };
  385. // True subtraction of nonnegative numbers yielding a nonnegative result.
  386. template<typename _R1, typename _R2>
  387. struct __ratio_add_impl<_R1, _R2, true, false, false>
  388. {
  389. private:
  390. static constexpr uintmax_t __g = __static_gcd<_R1::den, _R2::den>::value;
  391. static constexpr uintmax_t __d2 = _R2::den / __g;
  392. typedef __big_mul<_R1::den, __d2> __d;
  393. typedef __big_mul<_R1::num, _R2::den / __g> __x;
  394. typedef __big_mul<-_R2::num, _R1::den / __g> __y;
  395. typedef __big_sub<__x::__hi, __x::__lo, __y::__hi, __y::__lo> __n;
  396. typedef __big_div<__n::__hi, __n::__lo, __g> __ng;
  397. static constexpr uintmax_t __g2 = __static_gcd<__ng::__rem, __g>::value;
  398. typedef __big_div<__n::__hi, __n::__lo, __g2> __n_final;
  399. static_assert(__n_final::__rem == 0, "Internal library error");
  400. static_assert(__n_final::__quot_hi == 0 &&
  401. __n_final::__quot_lo <= __INTMAX_MAX__, "overflow in addition");
  402. typedef __big_mul<_R1::den / __g2, __d2> __d_final;
  403. static_assert(__d_final::__hi == 0 &&
  404. __d_final::__lo <= __INTMAX_MAX__, "overflow in addition");
  405. public:
  406. typedef ratio<__n_final::__quot_lo, __d_final::__lo> type;
  407. };
  408. template<typename _R1, typename _R2>
  409. struct __ratio_add
  410. {
  411. typedef typename __ratio_add_impl<_R1, _R2>::type type;
  412. static constexpr intmax_t num = type::num;
  413. static constexpr intmax_t den = type::den;
  414. };
  415. template<typename _R1, typename _R2>
  416. constexpr intmax_t __ratio_add<_R1, _R2>::num;
  417. template<typename _R1, typename _R2>
  418. constexpr intmax_t __ratio_add<_R1, _R2>::den;
  419. /// ratio_add
  420. template<typename _R1, typename _R2>
  421. using ratio_add = typename __ratio_add<_R1, _R2>::type;
  422. template<typename _R1, typename _R2>
  423. struct __ratio_subtract
  424. {
  425. typedef typename __ratio_add<
  426. _R1,
  427. ratio<-_R2::num, _R2::den>>::type type;
  428. static constexpr intmax_t num = type::num;
  429. static constexpr intmax_t den = type::den;
  430. };
  431. template<typename _R1, typename _R2>
  432. constexpr intmax_t __ratio_subtract<_R1, _R2>::num;
  433. template<typename _R1, typename _R2>
  434. constexpr intmax_t __ratio_subtract<_R1, _R2>::den;
  435. /// ratio_subtract
  436. template<typename _R1, typename _R2>
  437. using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type;
  438. typedef ratio<1, 1000000000000000000> atto;
  439. typedef ratio<1, 1000000000000000> femto;
  440. typedef ratio<1, 1000000000000> pico;
  441. typedef ratio<1, 1000000000> nano;
  442. typedef ratio<1, 1000000> micro;
  443. typedef ratio<1, 1000> milli;
  444. typedef ratio<1, 100> centi;
  445. typedef ratio<1, 10> deci;
  446. typedef ratio< 10, 1> deca;
  447. typedef ratio< 100, 1> hecto;
  448. typedef ratio< 1000, 1> kilo;
  449. typedef ratio< 1000000, 1> mega;
  450. typedef ratio< 1000000000, 1> giga;
  451. typedef ratio< 1000000000000, 1> tera;
  452. typedef ratio< 1000000000000000, 1> peta;
  453. typedef ratio< 1000000000000000000, 1> exa;
  454. // @} group ratio
  455. _GLIBCXX_END_NAMESPACE_VERSION
  456. } // namespace
  457. #endif //_GLIBCXX_USE_C99_STDINT_TR1
  458. #endif // C++11
  459. #endif //_GLIBCXX_RATIO