More compact versions of fminf() / fmaxf()

Includes a comment on what might appear as magic or
incomplete implementation at first sight.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6603 4a71c877-e1ca-e34f-864e-861f7616d084
master
Dennis Schridde 2009-02-09 04:07:44 +00:00
parent dd314e6cba
commit 0b09ace43a
1 changed files with 4 additions and 14 deletions

View File

@ -43,25 +43,15 @@
static inline float fmaxf(float x, float y)
{
if (isnan(x) && isnan(y))
return NAN;
else if (isnan(x))
return y;
else if (isnan(y))
return x;
return (x > y ? x : y);
/* Any comparison will return false if either of the arguments are NAN */
return (x > y || isnan(y) ? x : y);
}
static inline float fminf(float x, float y)
{
if (isnan(x) && isnan(y))
return NAN;
else if (isnan(x))
return y;
else if (isnan(y))
return x;
return (x > y ? y : x);
/* Any comparison will return false if either of the arguments are NAN */
return (x < y || isnan(y) ? x : y);
}