math: Move mathcommon.h to toplevel include.
[libcstd.git] / src / math / fmin.c
blob107cc62d663ef8f067ad6871f38fe941767f0878
1 /*
2 * fmin: floating point minimum function.
3 * Copyright (C) 2010 Nick Bowler.
5 * License LGPLv3+: GNU LGPL version 3 or later. See COPYING.LIB for terms.
6 * See <http://www.gnu.org/licenses/lgpl.html> if you did not receive a copy.
7 * This is free software: you are free to change and redistribute it.
8 * There is NO WARRANTY, to the extent permitted by law.
9 */
11 #include <cstd/mathcommon.h>
13 TYPE MF(fmin)(TYPE x, TYPE y)
15 if (isless(x, y) || isnan(y))
16 return x;
17 if (isless(y, x) || isnan(x))
18 return y;
19 if (signbit(x))
20 return x;
21 return y;