fmin/fmax

May 11, 2010 at 8:34pm
hi, need to write fmin and fmax functions
can anyhelp help implementing?

would this work?

double fmin(double a,double b)
{
return (a<b)?a:b;
}

double fmax(double a,double b)
{
return (b<a)?a:b;
}

thanks
May 11, 2010 at 8:49pm
Yes, except I would say a fmax() would read better as a>b rather than b<a. The former is instantly understandable while the latter takes a moment for one to recognize and process.
Topic archived. No new replies allowed.