Determine the maximum of two floating-point numbers
#include <math.h> double fmax( double x, double y ); float fmaxf( float x, float y ); long double fmaxl( long double x, long double y );
The fmax(), fmaxf(), and fmaxl() functions determine the maximum of two floating-point numbers.
To check for error situations, use feclearexcept() and fetestexcept(). For example:
The maximum of the arguments.
If: | These functions return: | Errors: |
---|---|---|
x and y are both NaN | NaN | — |
Just one of the arguments is NaN | The numeric value | — |
These functions raise FE_INEXACT if the FPU reports that the result can't be exactly represented as a floating-point number.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |