In C, fmaximum_num() returns the larger of two double values by numeric order. fmaximum_num(2.0, 9.0) is 9.0. Positive zero is treated as greater than negative zero.
If exactly one argument is NaN, the function returns the other number. You get NaN only when both are NaN. This belongs to the newer C23 math family in <math.h>. Your toolchain may need a newer C library before the name links.
Syntax
Pass two floating-point numbers. Start with this call.
C
fmaximum_num(2.0, 9.0);
Call
What it does
fmaximum_num(2.0, 9.0)
Returns 9.0, the larger value.
fmaximum_num(NAN, 4.0)
Prefers the number and returns 4.0.
Include <math.h>. On GCC, link with -lm. Needs C23-era support. For the classic “prefer non-NaN max” from older C, see fmax().
Library declarations
C
double fmaximum_num(double x, double y);
float fmaximum_numf(float x, float y);
long double fmaximum_numl(long double x, long double y);
Parameters
Parameter
Description
x
Required. First floating-point value.
y
Required. Second floating-point value.
Return Value
Return Value
Description
double
The larger argument. If one is NaN, returns the other. NaN only if both are NaN.