From Jason Turner

[ratio]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp9kllmpeh/{from.md → to.md} +17 -18
tmp/tmp9kllmpeh/{from.md → to.md} RENAMED
@@ -1,18 +1,18 @@
1
  ## Compile-time rational arithmetic <a id="ratio">[[ratio]]</a>
2
 
3
  ### In general <a id="ratio.general">[[ratio.general]]</a>
4
 
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 {
@@ -72,12 +72,11 @@ namespace std {
72
 
73
  ### Class template `ratio` <a id="ratio.ratio">[[ratio.ratio]]</a>
74
 
75
  ``` cpp
76
  namespace std {
77
- template <intmax_t N, intmax_t D = 1>
78
- class ratio {
79
  public:
80
  static constexpr intmax_t num;
81
  static constexpr intmax_t den;
82
  using type = ratio<num, den>;
83
  };
@@ -88,12 +87,12 @@ If the template argument `D` is zero or the absolute values of either of
88
  the template arguments `N` and `D` is not representable by type
89
  `intmax_t`, the program is ill-formed.
90
 
91
  [*Note 1*: These rules ensure that infinite ratios are avoided and that
92
  for any negative input, there exists a representable value of its
93
- absolute value which is positive. In a two’s complement representation,
94
- this excludes the most negative value. — *end note*]
95
 
96
  The static data members `num` and `den` shall have the following values,
97
  where `gcd` represents the greatest common divisor of the absolute
98
  values of `N` and `D`:
99
 
@@ -103,22 +102,22 @@ values of `N` and `D`:
103
  ### Arithmetic on `ratio`s <a id="ratio.arithmetic">[[ratio.arithmetic]]</a>
104
 
105
  Each of the alias templates `ratio_add`, `ratio_subtract`,
106
  `ratio_multiply`, and `ratio_divide` denotes the result of an arithmetic
107
  computation on two `ratio`s `R1` and `R2`. With `X` and `Y` computed (in
108
- the absence of arithmetic overflow) as specified by Table 
109
- [[tab:ratio.arithmetic]], each alias denotes a `ratio<U, V>` such that
110
- `U` is the same as `ratio<X, Y>::num` and `V` is the same as
111
  `ratio<X, Y>::den`.
112
 
113
  If it is not possible to represent `U` or `V` with `intmax_t`, the
114
  program is ill-formed. Otherwise, an implementation should yield correct
115
  values of `U` and `V`. If it is not possible to represent `X` or `Y`
116
  with `intmax_t`, the program is ill-formed unless the implementation
117
  yields correct values of `U` and `V`.
118
 
119
- **Table: Expressions used to perform ratio arithmetic** <a id="tab:ratio.arithmetic">[tab:ratio.arithmetic]</a>
120
 
121
  | Type | Value of `X` | Value of `Y` |
122
  | ------------------------ | --------------------- | ------------------- |
123
  | `ratio_add<R1, R2>` | `R1::num * R2::den +` | `R1::den * R2::den` |
124
  | | `R2::num * R1::den` | |
@@ -189,8 +188,8 @@ template <class R1, class R2>
189
 
190
  ### SI types for `ratio` <a id="ratio.si">[[ratio.si]]</a>
191
 
192
  For each of the *typedef-name*s `yocto`, `zepto`, `zetta`, and `yotta`,
193
  if both of the constants used in its specification are representable by
194
- `intmax_t`, the typedef shall be defined; if either of the constants is
195
- not representable by `intmax_t`, the typedef shall not be defined.
196
 
 
1
  ## Compile-time rational arithmetic <a id="ratio">[[ratio]]</a>
2
 
3
  ### In general <a id="ratio.general">[[ratio.general]]</a>
4
 
5
+ Subclause  [[ratio]] describes the ratio library. It provides a class
6
+ template `ratio` which exactly represents any finite rational number
7
+ with a numerator and denominator representable by compile-time constants
8
+ of type `intmax_t`.
9
 
10
+ Throughout subclause  [[ratio]], the names of template parameters are
11
+ used to express type requirements. If a template parameter is named `R1`
12
+ or `R2`, and the template argument is not a specialization of the
13
+ `ratio` template, the program is ill-formed.
14
 
15
  ### Header `<ratio>` synopsis <a id="ratio.syn">[[ratio.syn]]</a>
16
 
17
  ``` cpp
18
  namespace std {
 
72
 
73
  ### Class template `ratio` <a id="ratio.ratio">[[ratio.ratio]]</a>
74
 
75
  ``` cpp
76
  namespace std {
77
+ template<intmax_t N, intmax_t D = 1> class ratio {
 
78
  public:
79
  static constexpr intmax_t num;
80
  static constexpr intmax_t den;
81
  using type = ratio<num, den>;
82
  };
 
87
  the template arguments `N` and `D` is not representable by type
88
  `intmax_t`, the program is ill-formed.
89
 
90
  [*Note 1*: These rules ensure that infinite ratios are avoided and that
91
  for any negative input, there exists a representable value of its
92
+ absolute value which is positive. This excludes the most negative
93
+ value. — *end note*]
94
 
95
  The static data members `num` and `den` shall have the following values,
96
  where `gcd` represents the greatest common divisor of the absolute
97
  values of `N` and `D`:
98
 
 
102
  ### Arithmetic on `ratio`s <a id="ratio.arithmetic">[[ratio.arithmetic]]</a>
103
 
104
  Each of the alias templates `ratio_add`, `ratio_subtract`,
105
  `ratio_multiply`, and `ratio_divide` denotes the result of an arithmetic
106
  computation on two `ratio`s `R1` and `R2`. With `X` and `Y` computed (in
107
+ the absence of arithmetic overflow) as specified by
108
+ [[ratio.arithmetic]], each alias denotes a `ratio<U, V>` such that `U`
109
+ is the same as `ratio<X, Y>::num` and `V` is the same as
110
  `ratio<X, Y>::den`.
111
 
112
  If it is not possible to represent `U` or `V` with `intmax_t`, the
113
  program is ill-formed. Otherwise, an implementation should yield correct
114
  values of `U` and `V`. If it is not possible to represent `X` or `Y`
115
  with `intmax_t`, the program is ill-formed unless the implementation
116
  yields correct values of `U` and `V`.
117
 
118
+ **Table: Expressions used to perform ratio arithmetic** <a id="ratio.arithmetic">[ratio.arithmetic]</a>
119
 
120
  | Type | Value of `X` | Value of `Y` |
121
  | ------------------------ | --------------------- | ------------------- |
122
  | `ratio_add<R1, R2>` | `R1::num * R2::den +` | `R1::den * R2::den` |
123
  | | `R2::num * R1::den` | |
 
188
 
189
  ### SI types for `ratio` <a id="ratio.si">[[ratio.si]]</a>
190
 
191
  For each of the *typedef-name*s `yocto`, `zepto`, `zetta`, and `yotta`,
192
  if both of the constants used in its specification are representable by
193
+ `intmax_t`, the typedef is defined; if either of the constants is not
194
+ representable by `intmax_t`, the typedef is not defined.
195