libstdc++
|
00001 // ratio -*- C++ -*- 00002 00003 // Copyright (C) 2008-2019 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /** @file include/ratio 00026 * This is a Standard C++ Library header. 00027 */ 00028 00029 #ifndef _GLIBCXX_RATIO 00030 #define _GLIBCXX_RATIO 1 00031 00032 #pragma GCC system_header 00033 00034 #if __cplusplus < 201103L 00035 # include <bits/c++0x_warning.h> 00036 #else 00037 00038 #include <type_traits> 00039 #include <cstdint> // intmax_t, uintmax_t 00040 00041 namespace std _GLIBCXX_VISIBILITY(default) 00042 { 00043 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00044 00045 /** 00046 * @defgroup ratio Rational Arithmetic 00047 * @ingroup utilities 00048 * 00049 * Compile time representation of finite rational numbers. 00050 * @{ 00051 */ 00052 00053 template<intmax_t _Pn> 00054 struct __static_sign 00055 : integral_constant<intmax_t, (_Pn < 0) ? -1 : 1> 00056 { }; 00057 00058 template<intmax_t _Pn> 00059 struct __static_abs 00060 : integral_constant<intmax_t, _Pn * __static_sign<_Pn>::value> 00061 { }; 00062 00063 template<intmax_t _Pn, intmax_t _Qn> 00064 struct __static_gcd 00065 : __static_gcd<_Qn, (_Pn % _Qn)> 00066 { }; 00067 00068 template<intmax_t _Pn> 00069 struct __static_gcd<_Pn, 0> 00070 : integral_constant<intmax_t, __static_abs<_Pn>::value> 00071 { }; 00072 00073 template<intmax_t _Qn> 00074 struct __static_gcd<0, _Qn> 00075 : integral_constant<intmax_t, __static_abs<_Qn>::value> 00076 { }; 00077 00078 // Let c = 2^(half # of bits in an intmax_t) 00079 // then we find a1, a0, b1, b0 s.t. N = a1*c + a0, M = b1*c + b0 00080 // The multiplication of N and M becomes, 00081 // N * M = (a1 * b1)c^2 + (a0 * b1 + b0 * a1)c + a0 * b0 00082 // Multiplication is safe if each term and the sum of the terms 00083 // is representable by intmax_t. 00084 template<intmax_t _Pn, intmax_t _Qn> 00085 struct __safe_multiply 00086 { 00087 private: 00088 static const uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4); 00089 00090 static const uintmax_t __a0 = __static_abs<_Pn>::value % __c; 00091 static const uintmax_t __a1 = __static_abs<_Pn>::value / __c; 00092 static const uintmax_t __b0 = __static_abs<_Qn>::value % __c; 00093 static const uintmax_t __b1 = __static_abs<_Qn>::value / __c; 00094 00095 static_assert(__a1 == 0 || __b1 == 0, 00096 "overflow in multiplication"); 00097 static_assert(__a0 * __b1 + __b0 * __a1 < (__c >> 1), 00098 "overflow in multiplication"); 00099 static_assert(__b0 * __a0 <= __INTMAX_MAX__, 00100 "overflow in multiplication"); 00101 static_assert((__a0 * __b1 + __b0 * __a1) * __c 00102 <= __INTMAX_MAX__ - __b0 * __a0, 00103 "overflow in multiplication"); 00104 00105 public: 00106 static const intmax_t value = _Pn * _Qn; 00107 }; 00108 00109 // Some double-precision utilities, where numbers are represented as 00110 // __hi*2^(8*sizeof(uintmax_t)) + __lo. 00111 template<uintmax_t __hi1, uintmax_t __lo1, uintmax_t __hi2, uintmax_t __lo2> 00112 struct __big_less 00113 : integral_constant<bool, (__hi1 < __hi2 00114 || (__hi1 == __hi2 && __lo1 < __lo2))> 00115 { }; 00116 00117 template<uintmax_t __hi1, uintmax_t __lo1, uintmax_t __hi2, uintmax_t __lo2> 00118 struct __big_add 00119 { 00120 static constexpr uintmax_t __lo = __lo1 + __lo2; 00121 static constexpr uintmax_t __hi = (__hi1 + __hi2 + 00122 (__lo1 + __lo2 < __lo1)); // carry 00123 }; 00124 00125 // Subtract a number from a bigger one. 00126 template<uintmax_t __hi1, uintmax_t __lo1, uintmax_t __hi2, uintmax_t __lo2> 00127 struct __big_sub 00128 { 00129 static_assert(!__big_less<__hi1, __lo1, __hi2, __lo2>::value, 00130 "Internal library error"); 00131 static constexpr uintmax_t __lo = __lo1 - __lo2; 00132 static constexpr uintmax_t __hi = (__hi1 - __hi2 - 00133 (__lo1 < __lo2)); // carry 00134 }; 00135 00136 // Same principle as __safe_multiply. 00137 template<uintmax_t __x, uintmax_t __y> 00138 struct __big_mul 00139 { 00140 private: 00141 static constexpr uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4); 00142 static constexpr uintmax_t __x0 = __x % __c; 00143 static constexpr uintmax_t __x1 = __x / __c; 00144 static constexpr uintmax_t __y0 = __y % __c; 00145 static constexpr uintmax_t __y1 = __y / __c; 00146 static constexpr uintmax_t __x0y0 = __x0 * __y0; 00147 static constexpr uintmax_t __x0y1 = __x0 * __y1; 00148 static constexpr uintmax_t __x1y0 = __x1 * __y0; 00149 static constexpr uintmax_t __x1y1 = __x1 * __y1; 00150 static constexpr uintmax_t __mix = __x0y1 + __x1y0; // possible carry... 00151 static constexpr uintmax_t __mix_lo = __mix * __c; 00152 static constexpr uintmax_t __mix_hi 00153 = __mix / __c + ((__mix < __x0y1) ? __c : 0); // ... added here 00154 typedef __big_add<__mix_hi, __mix_lo, __x1y1, __x0y0> _Res; 00155 public: 00156 static constexpr uintmax_t __hi = _Res::__hi; 00157 static constexpr uintmax_t __lo = _Res::__lo; 00158 }; 00159 00160 // Adapted from __udiv_qrnnd_c in longlong.h 00161 // This version assumes that the high bit of __d is 1. 00162 template<uintmax_t __n1, uintmax_t __n0, uintmax_t __d> 00163 struct __big_div_impl 00164 { 00165 private: 00166 static_assert(__d >= (uintmax_t(1) << (sizeof(intmax_t) * 8 - 1)), 00167 "Internal library error"); 00168 static_assert(__n1 < __d, "Internal library error"); 00169 static constexpr uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4); 00170 static constexpr uintmax_t __d1 = __d / __c; 00171 static constexpr uintmax_t __d0 = __d % __c; 00172 00173 static constexpr uintmax_t __q1x = __n1 / __d1; 00174 static constexpr uintmax_t __r1x = __n1 % __d1; 00175 static constexpr uintmax_t __m = __q1x * __d0; 00176 static constexpr uintmax_t __r1y = __r1x * __c + __n0 / __c; 00177 static constexpr uintmax_t __r1z = __r1y + __d; 00178 static constexpr uintmax_t __r1 00179 = ((__r1y < __m) ? ((__r1z >= __d) && (__r1z < __m)) 00180 ? (__r1z + __d) : __r1z : __r1y) - __m; 00181 static constexpr uintmax_t __q1 00182 = __q1x - ((__r1y < __m) 00183 ? ((__r1z >= __d) && (__r1z < __m)) ? 2 : 1 : 0); 00184 static constexpr uintmax_t __q0x = __r1 / __d1; 00185 static constexpr uintmax_t __r0x = __r1 % __d1; 00186 static constexpr uintmax_t __n = __q0x * __d0; 00187 static constexpr uintmax_t __r0y = __r0x * __c + __n0 % __c; 00188 static constexpr uintmax_t __r0z = __r0y + __d; 00189 static constexpr uintmax_t __r0 00190 = ((__r0y < __n) ? ((__r0z >= __d) && (__r0z < __n)) 00191 ? (__r0z + __d) : __r0z : __r0y) - __n; 00192 static constexpr uintmax_t __q0 00193 = __q0x - ((__r0y < __n) ? ((__r0z >= __d) 00194 && (__r0z < __n)) ? 2 : 1 : 0); 00195 00196 public: 00197 static constexpr uintmax_t __quot = __q1 * __c + __q0; 00198 static constexpr uintmax_t __rem = __r0; 00199 00200 private: 00201 typedef __big_mul<__quot, __d> _Prod; 00202 typedef __big_add<_Prod::__hi, _Prod::__lo, 0, __rem> _Sum; 00203 static_assert(_Sum::__hi == __n1 && _Sum::__lo == __n0, 00204 "Internal library error"); 00205 }; 00206 00207 template<uintmax_t __n1, uintmax_t __n0, uintmax_t __d> 00208 struct __big_div 00209 { 00210 private: 00211 static_assert(__d != 0, "Internal library error"); 00212 static_assert(sizeof (uintmax_t) == sizeof (unsigned long long), 00213 "This library calls __builtin_clzll on uintmax_t, which " 00214 "is unsafe on your platform. Please complain to " 00215 "http://gcc.gnu.org/bugzilla/"); 00216 static constexpr int __shift = __builtin_clzll(__d); 00217 static constexpr int __coshift_ = sizeof(uintmax_t) * 8 - __shift; 00218 static constexpr int __coshift = (__shift != 0) ? __coshift_ : 0; 00219 static constexpr uintmax_t __c1 = uintmax_t(1) << __shift; 00220 static constexpr uintmax_t __c2 = uintmax_t(1) << __coshift; 00221 static constexpr uintmax_t __new_d = __d * __c1; 00222 static constexpr uintmax_t __new_n0 = __n0 * __c1; 00223 static constexpr uintmax_t __n1_shifted = (__n1 % __d) * __c1; 00224 static constexpr uintmax_t __n0_top = (__shift != 0) ? (__n0 / __c2) : 0; 00225 static constexpr uintmax_t __new_n1 = __n1_shifted + __n0_top; 00226 typedef __big_div_impl<__new_n1, __new_n0, __new_d> _Res; 00227 00228 public: 00229 static constexpr uintmax_t __quot_hi = __n1 / __d; 00230 static constexpr uintmax_t __quot_lo = _Res::__quot; 00231 static constexpr uintmax_t __rem = _Res::__rem / __c1; 00232 00233 private: 00234 typedef __big_mul<__quot_lo, __d> _P0; 00235 typedef __big_mul<__quot_hi, __d> _P1; 00236 typedef __big_add<_P0::__hi, _P0::__lo, _P1::__lo, __rem> _Sum; 00237 // No overflow. 00238 static_assert(_P1::__hi == 0, "Internal library error"); 00239 static_assert(_Sum::__hi >= _P0::__hi, "Internal library error"); 00240 // Matches the input data. 00241 static_assert(_Sum::__hi == __n1 && _Sum::__lo == __n0, 00242 "Internal library error"); 00243 static_assert(__rem < __d, "Internal library error"); 00244 }; 00245 00246 /** 00247 * @brief Provides compile-time rational arithmetic. 00248 * 00249 * This class template represents any finite rational number with a 00250 * numerator and denominator representable by compile-time constants of 00251 * type intmax_t. The ratio is simplified when instantiated. 00252 * 00253 * For example: 00254 * @code 00255 * std::ratio<7,-21>::num == -1; 00256 * std::ratio<7,-21>::den == 3; 00257 * @endcode 00258 * 00259 */ 00260 template<intmax_t _Num, intmax_t _Den = 1> 00261 struct ratio 00262 { 00263 static_assert(_Den != 0, "denominator cannot be zero"); 00264 static_assert(_Num >= -__INTMAX_MAX__ && _Den >= -__INTMAX_MAX__, 00265 "out of range"); 00266 00267 // Note: sign(N) * abs(N) == N 00268 static constexpr intmax_t num = 00269 _Num * __static_sign<_Den>::value / __static_gcd<_Num, _Den>::value; 00270 00271 static constexpr intmax_t den = 00272 __static_abs<_Den>::value / __static_gcd<_Num, _Den>::value; 00273 00274 typedef ratio<num, den> type; 00275 }; 00276 00277 template<intmax_t _Num, intmax_t _Den> 00278 constexpr intmax_t ratio<_Num, _Den>::num; 00279 00280 template<intmax_t _Num, intmax_t _Den> 00281 constexpr intmax_t ratio<_Num, _Den>::den; 00282 00283 template<typename _R1, typename _R2> 00284 struct __ratio_multiply 00285 { 00286 private: 00287 static const intmax_t __gcd1 = 00288 __static_gcd<_R1::num, _R2::den>::value; 00289 static const intmax_t __gcd2 = 00290 __static_gcd<_R2::num, _R1::den>::value; 00291 00292 public: 00293 typedef ratio< 00294 __safe_multiply<(_R1::num / __gcd1), 00295 (_R2::num / __gcd2)>::value, 00296 __safe_multiply<(_R1::den / __gcd2), 00297 (_R2::den / __gcd1)>::value> type; 00298 00299 static constexpr intmax_t num = type::num; 00300 static constexpr intmax_t den = type::den; 00301 }; 00302 00303 template<typename _R1, typename _R2> 00304 constexpr intmax_t __ratio_multiply<_R1, _R2>::num; 00305 00306 template<typename _R1, typename _R2> 00307 constexpr intmax_t __ratio_multiply<_R1, _R2>::den; 00308 00309 /// ratio_multiply 00310 template<typename _R1, typename _R2> 00311 using ratio_multiply = typename __ratio_multiply<_R1, _R2>::type; 00312 00313 template<typename _R1, typename _R2> 00314 struct __ratio_divide 00315 { 00316 static_assert(_R2::num != 0, "division by 0"); 00317 00318 typedef typename __ratio_multiply< 00319 _R1, 00320 ratio<_R2::den, _R2::num>>::type type; 00321 00322 static constexpr intmax_t num = type::num; 00323 static constexpr intmax_t den = type::den; 00324 }; 00325 00326 template<typename _R1, typename _R2> 00327 constexpr intmax_t __ratio_divide<_R1, _R2>::num; 00328 00329 template<typename _R1, typename _R2> 00330 constexpr intmax_t __ratio_divide<_R1, _R2>::den; 00331 00332 /// ratio_divide 00333 template<typename _R1, typename _R2> 00334 using ratio_divide = typename __ratio_divide<_R1, _R2>::type; 00335 00336 /// ratio_equal 00337 template<typename _R1, typename _R2> 00338 struct ratio_equal 00339 : integral_constant<bool, _R1::num == _R2::num && _R1::den == _R2::den> 00340 { }; 00341 00342 /// ratio_not_equal 00343 template<typename _R1, typename _R2> 00344 struct ratio_not_equal 00345 : integral_constant<bool, !ratio_equal<_R1, _R2>::value> 00346 { }; 00347 00348 // Both numbers are positive. 00349 template<typename _R1, typename _R2, 00350 typename _Left = __big_mul<_R1::num,_R2::den>, 00351 typename _Right = __big_mul<_R2::num,_R1::den> > 00352 struct __ratio_less_impl_1 00353 : integral_constant<bool, __big_less<_Left::__hi, _Left::__lo, 00354 _Right::__hi, _Right::__lo>::value> 00355 { }; 00356 00357 template<typename _R1, typename _R2, 00358 bool = (_R1::num == 0 || _R2::num == 0 00359 || (__static_sign<_R1::num>::value 00360 != __static_sign<_R2::num>::value)), 00361 bool = (__static_sign<_R1::num>::value == -1 00362 && __static_sign<_R2::num>::value == -1)> 00363 struct __ratio_less_impl 00364 : __ratio_less_impl_1<_R1, _R2>::type 00365 { }; 00366 00367 template<typename _R1, typename _R2> 00368 struct __ratio_less_impl<_R1, _R2, true, false> 00369 : integral_constant<bool, _R1::num < _R2::num> 00370 { }; 00371 00372 template<typename _R1, typename _R2> 00373 struct __ratio_less_impl<_R1, _R2, false, true> 00374 : __ratio_less_impl_1<ratio<-_R2::num, _R2::den>, 00375 ratio<-_R1::num, _R1::den> >::type 00376 { }; 00377 00378 /// ratio_less 00379 template<typename _R1, typename _R2> 00380 struct ratio_less 00381 : __ratio_less_impl<_R1, _R2>::type 00382 { }; 00383 00384 /// ratio_less_equal 00385 template<typename _R1, typename _R2> 00386 struct ratio_less_equal 00387 : integral_constant<bool, !ratio_less<_R2, _R1>::value> 00388 { }; 00389 00390 /// ratio_greater 00391 template<typename _R1, typename _R2> 00392 struct ratio_greater 00393 : integral_constant<bool, ratio_less<_R2, _R1>::value> 00394 { }; 00395 00396 /// ratio_greater_equal 00397 template<typename _R1, typename _R2> 00398 struct ratio_greater_equal 00399 : integral_constant<bool, !ratio_less<_R1, _R2>::value> 00400 { }; 00401 00402 #if __cplusplus > 201402L 00403 template <typename _R1, typename _R2> 00404 inline constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value; 00405 template <typename _R1, typename _R2> 00406 inline constexpr bool ratio_not_equal_v = ratio_not_equal<_R1, _R2>::value; 00407 template <typename _R1, typename _R2> 00408 inline constexpr bool ratio_less_v = ratio_less<_R1, _R2>::value; 00409 template <typename _R1, typename _R2> 00410 inline constexpr bool ratio_less_equal_v = 00411 ratio_less_equal<_R1, _R2>::value; 00412 template <typename _R1, typename _R2> 00413 inline constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value; 00414 template <typename _R1, typename _R2> 00415 inline constexpr bool ratio_greater_equal_v 00416 = ratio_greater_equal<_R1, _R2>::value; 00417 #endif // C++17 00418 00419 template<typename _R1, typename _R2, 00420 bool = (_R1::num >= 0), 00421 bool = (_R2::num >= 0), 00422 bool = ratio_less<ratio<__static_abs<_R1::num>::value, _R1::den>, 00423 ratio<__static_abs<_R2::num>::value, _R2::den> >::value> 00424 struct __ratio_add_impl 00425 { 00426 private: 00427 typedef typename __ratio_add_impl< 00428 ratio<-_R1::num, _R1::den>, 00429 ratio<-_R2::num, _R2::den> >::type __t; 00430 public: 00431 typedef ratio<-__t::num, __t::den> type; 00432 }; 00433 00434 // True addition of nonnegative numbers. 00435 template<typename _R1, typename _R2, bool __b> 00436 struct __ratio_add_impl<_R1, _R2, true, true, __b> 00437 { 00438 private: 00439 static constexpr uintmax_t __g = __static_gcd<_R1::den, _R2::den>::value; 00440 static constexpr uintmax_t __d2 = _R2::den / __g; 00441 typedef __big_mul<_R1::den, __d2> __d; 00442 typedef __big_mul<_R1::num, _R2::den / __g> __x; 00443 typedef __big_mul<_R2::num, _R1::den / __g> __y; 00444 typedef __big_add<__x::__hi, __x::__lo, __y::__hi, __y::__lo> __n; 00445 static_assert(__n::__hi >= __x::__hi, "Internal library error"); 00446 typedef __big_div<__n::__hi, __n::__lo, __g> __ng; 00447 static constexpr uintmax_t __g2 = __static_gcd<__ng::__rem, __g>::value; 00448 typedef __big_div<__n::__hi, __n::__lo, __g2> __n_final; 00449 static_assert(__n_final::__rem == 0, "Internal library error"); 00450 static_assert(__n_final::__quot_hi == 0 && 00451 __n_final::__quot_lo <= __INTMAX_MAX__, "overflow in addition"); 00452 typedef __big_mul<_R1::den / __g2, __d2> __d_final; 00453 static_assert(__d_final::__hi == 0 && 00454 __d_final::__lo <= __INTMAX_MAX__, "overflow in addition"); 00455 public: 00456 typedef ratio<__n_final::__quot_lo, __d_final::__lo> type; 00457 }; 00458 00459 template<typename _R1, typename _R2> 00460 struct __ratio_add_impl<_R1, _R2, false, true, true> 00461 : __ratio_add_impl<_R2, _R1> 00462 { }; 00463 00464 // True subtraction of nonnegative numbers yielding a nonnegative result. 00465 template<typename _R1, typename _R2> 00466 struct __ratio_add_impl<_R1, _R2, true, false, false> 00467 { 00468 private: 00469 static constexpr uintmax_t __g = __static_gcd<_R1::den, _R2::den>::value; 00470 static constexpr uintmax_t __d2 = _R2::den / __g; 00471 typedef __big_mul<_R1::den, __d2> __d; 00472 typedef __big_mul<_R1::num, _R2::den / __g> __x; 00473 typedef __big_mul<-_R2::num, _R1::den / __g> __y; 00474 typedef __big_sub<__x::__hi, __x::__lo, __y::__hi, __y::__lo> __n; 00475 typedef __big_div<__n::__hi, __n::__lo, __g> __ng; 00476 static constexpr uintmax_t __g2 = __static_gcd<__ng::__rem, __g>::value; 00477 typedef __big_div<__n::__hi, __n::__lo, __g2> __n_final; 00478 static_assert(__n_final::__rem == 0, "Internal library error"); 00479 static_assert(__n_final::__quot_hi == 0 && 00480 __n_final::__quot_lo <= __INTMAX_MAX__, "overflow in addition"); 00481 typedef __big_mul<_R1::den / __g2, __d2> __d_final; 00482 static_assert(__d_final::__hi == 0 && 00483 __d_final::__lo <= __INTMAX_MAX__, "overflow in addition"); 00484 public: 00485 typedef ratio<__n_final::__quot_lo, __d_final::__lo> type; 00486 }; 00487 00488 template<typename _R1, typename _R2> 00489 struct __ratio_add 00490 { 00491 typedef typename __ratio_add_impl<_R1, _R2>::type type; 00492 static constexpr intmax_t num = type::num; 00493 static constexpr intmax_t den = type::den; 00494 }; 00495 00496 template<typename _R1, typename _R2> 00497 constexpr intmax_t __ratio_add<_R1, _R2>::num; 00498 00499 template<typename _R1, typename _R2> 00500 constexpr intmax_t __ratio_add<_R1, _R2>::den; 00501 00502 /// ratio_add 00503 template<typename _R1, typename _R2> 00504 using ratio_add = typename __ratio_add<_R1, _R2>::type; 00505 00506 template<typename _R1, typename _R2> 00507 struct __ratio_subtract 00508 { 00509 typedef typename __ratio_add< 00510 _R1, 00511 ratio<-_R2::num, _R2::den>>::type type; 00512 00513 static constexpr intmax_t num = type::num; 00514 static constexpr intmax_t den = type::den; 00515 }; 00516 00517 template<typename _R1, typename _R2> 00518 constexpr intmax_t __ratio_subtract<_R1, _R2>::num; 00519 00520 template<typename _R1, typename _R2> 00521 constexpr intmax_t __ratio_subtract<_R1, _R2>::den; 00522 00523 /// ratio_subtract 00524 template<typename _R1, typename _R2> 00525 using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type; 00526 00527 00528 typedef ratio<1, 1000000000000000000> atto; 00529 typedef ratio<1, 1000000000000000> femto; 00530 typedef ratio<1, 1000000000000> pico; 00531 typedef ratio<1, 1000000000> nano; 00532 typedef ratio<1, 1000000> micro; 00533 typedef ratio<1, 1000> milli; 00534 typedef ratio<1, 100> centi; 00535 typedef ratio<1, 10> deci; 00536 typedef ratio< 10, 1> deca; 00537 typedef ratio< 100, 1> hecto; 00538 typedef ratio< 1000, 1> kilo; 00539 typedef ratio< 1000000, 1> mega; 00540 typedef ratio< 1000000000, 1> giga; 00541 typedef ratio< 1000000000000, 1> tera; 00542 typedef ratio< 1000000000000000, 1> peta; 00543 typedef ratio< 1000000000000000000, 1> exa; 00544 00545 // @} group ratio 00546 _GLIBCXX_END_NAMESPACE_VERSION 00547 } // namespace 00548 00549 #endif // C++11 00550 00551 #endif //_GLIBCXX_RATIO