blob: ff7a2328936b140ad7a33fb76d251c507e5ecafa [file] [log] [blame]
Viet-Trung Luu96b05c12016-01-11 11:26:36 -08001#include <math.h>
2
George Kulakowski17e3b042016-02-18 15:59:50 -08003double fmax(double x, double y) {
4 if (isnan(x))
5 return y;
6 if (isnan(y))
7 return x;
8 /* handle signed zeros, see C99 Annex F.9.9.2 */
9 if (signbit(x) != signbit(y))
10 return signbit(x) ? y : x;
11 return x < y ? y : x;
Viet-Trung Luu96b05c12016-01-11 11:26:36 -080012}