@@ -147,24 +147,23 @@ for ( i = 0; i < 100; i++ ) {
147
147
148
148
#### stdlib_base_minmax( x, y, &min, &max )
149
149
150
- Returns the minimum and maximum value .
150
+ Evaluates the minimum and maximum values in a single pass .
151
151
152
152
``` c
153
- #include < stdint.h>
153
+ double x = 3.14 ;
154
+ double y = 2.71 ;
154
155
155
156
double min;
156
157
double max;
157
-
158
- stdlib_base_minmax ( 3.14, NaN );
159
- // returns [ NaN, NaN ]
158
+ stdlib_base_minmax ( x, y, &min, &max );
160
159
```
161
160
162
161
The function accepts the following arguments:
163
162
164
- - **x**: `[in] double` input value .
165
- - **y**: `[in] double` input value .
166
- - **min**: `[out] double` destination for minimum value.
167
- - **max**: `[out] double` destination for maximum value.
163
+ - **x**: `[in] double` first number .
164
+ - **y**: `[in] double` second number .
165
+ - **min**: `[out] double` destination for the minimum value.
166
+ - **max**: `[out] double` destination for the maximum value.
168
167
169
168
```c
170
169
void stdlib_base_minmax( const double x, const double y, double* min, double* max );
@@ -190,24 +189,18 @@ void stdlib_base_minmax( const double x, const double y, double* min, double* ma
190
189
191
190
``` c
192
191
#include " stdlib/math/base/special/minmax.h"
193
- #include < stdlib.h>
194
192
#include < stdio.h>
195
193
196
194
int main ( void ) {
195
+ const double x[ ] = { 1.0, 0.45, -0.89, 0.0 / 0.0, -0.78, -0.22, 0.66, 0.11, -0.55, 0.0 };
196
+ const double y[ ] = { -0.22, 0.66, 0.0, -0.55, 0.33, 1.0, 0.0 / 0.0, 0.11, 0.45, -0.78 };
197
+
197
198
double min;
198
199
double max;
199
- double x;
200
- double y;
201
200
int i;
202
-
203
- const double x1[] = { 1.0, 0.45, -0.89, 0.0 / 0.0, -0.78, -0.22, 0.66, 0.11, -0.55, 0.0 };
204
- const double x2[] = { -0.22, 0.66, 0.0, -0.55, 0.33, 1.0, 0.0 / 0.0, 0.11, 0.45, -0.78 };
205
-
206
- for ( i = 0; i < 12; i++ ) {
207
- x = ( ( (double)rand() / (double)RAND_MAX ) * 200.0 ) - 100.0;
208
- y = ( ( (double)rand() / (double)RAND_MAX ) * 200.0 ) - 100.0;
201
+ for ( i = 0; i < 10; i++ ) {
209
202
stdlib_base_minmax( x[ i ], y[ i ], &min, &max );
210
- printf( "x: %lf => min : %lf, y : %lf, minmax(x, y) : %lf\n", x[ i ], y[ i ]min, max );
203
+ printf( "x: %lf, y : %lf => min : %lf, max : %lf\n", x[ i ], y[ i ], min, max );
211
204
}
212
205
}
213
206
```
0 commit comments