xref: /haiku/src/system/libroot/posix/musl/math/fmin.c (revision f504f61099b010fbfa94b1cc63d2e9072c7f7185)
1*f504f610SAugustin Cavalier #include <math.h>
2*f504f610SAugustin Cavalier 
fmin(double x,double y)3*f504f610SAugustin Cavalier double fmin(double x, double y)
4*f504f610SAugustin Cavalier {
5*f504f610SAugustin Cavalier 	if (isnan(x))
6*f504f610SAugustin Cavalier 		return y;
7*f504f610SAugustin Cavalier 	if (isnan(y))
8*f504f610SAugustin Cavalier 		return x;
9*f504f610SAugustin Cavalier 	/* handle signed zeros, see C99 Annex F.9.9.2 */
10*f504f610SAugustin Cavalier 	if (signbit(x) != signbit(y))
11*f504f610SAugustin Cavalier 		return signbit(x) ? x : y;
12*f504f610SAugustin Cavalier 	return x < y ? x : y;
13*f504f610SAugustin Cavalier }
14