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-861f7616d084master
parent
dd314e6cba
commit
0b09ace43a
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue