1 /* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
2 *
3 * Permission to use, copy, modify, and distribute this software
4 * is freely granted, provided that this notice is preserved.
5 */
6 /*
7 FUNCTION
8 <<fmin>>, <<fminf>>---minimum
9 INDEX
10 fmin
11 INDEX
12 fminf
13
14 SYNOPSIS
15 #include <math.h>
16 double fmin(double <[x]>, double <[y]>);
17 float fminf(float <[x]>, float <[y]>);
18
19 DESCRIPTION
20 The <<fmin>> functions determine the minimum numeric value of their arguments.
21 NaN arguments are treated as missing data: if one argument is a NaN and the
22 other numeric, then the <<fmin>> functions choose the numeric value.
23
24 RETURNS
25 The <<fmin>> functions return the minimum numeric value of their arguments.
26
27 PORTABILITY
28 ANSI C, POSIX.
29
30 */
31
32 #include "fdlibm.h"
33
34 #ifdef _NEED_FLOAT64
35
36 __float64
fmin64(__float64 x,__float64 y)37 fmin64(__float64 x, __float64 y)
38 {
39 if (issignaling(x) || issignaling(y))
40 return x + y;
41
42 if (isnan(x))
43 return y;
44
45 if (isnan(y))
46 return x;
47
48 return x < y ? x : y;
49 }
50
51 _MATH_ALIAS_d_dd(fmin)
52
53 #endif /* _NEED_FLOAT64 */
54