tmp/tmp3xwd6_5j/{from.md → to.md}
RENAMED
|
@@ -5,13 +5,14 @@
|
|
| 5 |
This subclause describes the ratio library. It provides a class template
|
| 6 |
`ratio` which exactly represents any finite rational number with a
|
| 7 |
numerator and denominator representable by compile-time constants of
|
| 8 |
type `intmax_t`.
|
| 9 |
|
| 10 |
-
Throughout this subclause,
|
| 11 |
-
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
### Header `<ratio>` synopsis <a id="ratio.syn">[[ratio.syn]]</a>
|
| 15 |
|
| 16 |
``` cpp
|
| 17 |
namespace std {
|
|
@@ -31,43 +32,43 @@ namespace std {
|
|
| 31 |
template <class R1, class R2> struct ratio_less_equal;
|
| 32 |
template <class R1, class R2> struct ratio_greater;
|
| 33 |
template <class R1, class R2> struct ratio_greater_equal;
|
| 34 |
|
| 35 |
// [ratio.si], convenience SI typedefs
|
| 36 |
-
typedef ratio<1,
|
| 37 |
-
typedef ratio<1,
|
| 38 |
-
typedef ratio<1,
|
| 39 |
-
typedef ratio<1,
|
| 40 |
-
typedef ratio<1,
|
| 41 |
-
typedef ratio<1,
|
| 42 |
-
typedef ratio<1,
|
| 43 |
-
typedef ratio<1,
|
| 44 |
typedef ratio<1, 100> centi;
|
| 45 |
typedef ratio<1, 10> deci;
|
| 46 |
typedef ratio< 10, 1> deca;
|
| 47 |
typedef ratio< 100, 1> hecto;
|
| 48 |
-
typedef ratio<
|
| 49 |
-
typedef ratio<
|
| 50 |
-
typedef ratio<
|
| 51 |
-
typedef ratio<
|
| 52 |
-
typedef ratio<
|
| 53 |
-
typedef ratio<
|
| 54 |
-
typedef ratio<
|
| 55 |
-
typedef ratio<
|
| 56 |
}
|
| 57 |
```
|
| 58 |
|
| 59 |
### Class template `ratio` <a id="ratio.ratio">[[ratio.ratio]]</a>
|
| 60 |
|
| 61 |
``` cpp
|
| 62 |
namespace std {
|
| 63 |
template <intmax_t N, intmax_t D = 1>
|
| 64 |
class ratio {
|
| 65 |
public:
|
| 66 |
-
typedef ratio<num, den> type;
|
| 67 |
static constexpr intmax_t num;
|
| 68 |
static constexpr intmax_t den;
|
|
|
|
| 69 |
};
|
| 70 |
}
|
| 71 |
```
|
| 72 |
|
| 73 |
If the template argument `D` is zero or the absolute values of either of
|
|
|
|
| 5 |
This subclause describes the ratio library. It provides a class template
|
| 6 |
`ratio` which exactly represents any finite rational number with a
|
| 7 |
numerator and denominator representable by compile-time constants of
|
| 8 |
type `intmax_t`.
|
| 9 |
|
| 10 |
+
Throughout this subclause, the names of template parameters are used to
|
| 11 |
+
express type requirements. If a template parameter is named `R1` or
|
| 12 |
+
`R2`, and the template argument is not a specialization of the `ratio`
|
| 13 |
+
template, the program is ill-formed.
|
| 14 |
|
| 15 |
### Header `<ratio>` synopsis <a id="ratio.syn">[[ratio.syn]]</a>
|
| 16 |
|
| 17 |
``` cpp
|
| 18 |
namespace std {
|
|
|
|
| 32 |
template <class R1, class R2> struct ratio_less_equal;
|
| 33 |
template <class R1, class R2> struct ratio_greater;
|
| 34 |
template <class R1, class R2> struct ratio_greater_equal;
|
| 35 |
|
| 36 |
// [ratio.si], convenience SI typedefs
|
| 37 |
+
typedef ratio<1, 1'000'000'000'000'000'000'000'000> yocto; // see below
|
| 38 |
+
typedef ratio<1, 1'000'000'000'000'000'000'000> zepto; // see below
|
| 39 |
+
typedef ratio<1, 1'000'000'000'000'000'000> atto;
|
| 40 |
+
typedef ratio<1, 1'000'000'000'000'000> femto;
|
| 41 |
+
typedef ratio<1, 1'000'000'000'000> pico;
|
| 42 |
+
typedef ratio<1, 1'000'000'000> nano;
|
| 43 |
+
typedef ratio<1, 1'000'000> micro;
|
| 44 |
+
typedef ratio<1, 1'000> milli;
|
| 45 |
typedef ratio<1, 100> centi;
|
| 46 |
typedef ratio<1, 10> deci;
|
| 47 |
typedef ratio< 10, 1> deca;
|
| 48 |
typedef ratio< 100, 1> hecto;
|
| 49 |
+
typedef ratio< 1'000, 1> kilo;
|
| 50 |
+
typedef ratio< 1'000'000, 1> mega;
|
| 51 |
+
typedef ratio< 1'000'000'000, 1> giga;
|
| 52 |
+
typedef ratio< 1'000'000'000'000, 1> tera;
|
| 53 |
+
typedef ratio< 1'000'000'000'000'000, 1> peta;
|
| 54 |
+
typedef ratio< 1'000'000'000'000'000'000, 1> exa;
|
| 55 |
+
typedef ratio< 1'000'000'000'000'000'000'000, 1> zetta; // see below
|
| 56 |
+
typedef ratio<1'000'000'000'000'000'000'000'000, 1> yotta; // see below
|
| 57 |
}
|
| 58 |
```
|
| 59 |
|
| 60 |
### Class template `ratio` <a id="ratio.ratio">[[ratio.ratio]]</a>
|
| 61 |
|
| 62 |
``` cpp
|
| 63 |
namespace std {
|
| 64 |
template <intmax_t N, intmax_t D = 1>
|
| 65 |
class ratio {
|
| 66 |
public:
|
|
|
|
| 67 |
static constexpr intmax_t num;
|
| 68 |
static constexpr intmax_t den;
|
| 69 |
+
typedef ratio<num, den> type;
|
| 70 |
};
|
| 71 |
}
|
| 72 |
```
|
| 73 |
|
| 74 |
If the template argument `D` is zero or the absolute values of either of
|