You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

577 lines
20KB

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