Node:Misc FP Arithmetic, Previous:FP Comparison Functions, Up:Arithmetic Functions
The functions in this section perform miscellaneous but common operations that are awkward to express with C operators. On some processors these functions can use special machine instructions to perform these operations faster than the equivalent C code.
double fmin (double x, double y) | Function |
float fminf (float x, float y) | Function |
long double fminl (long double x, long double y) | Function |
The fmin function returns the lesser of the two values x
and y. It is similar to the expression
((x) < (y) ? (x) : (y))except that x and y are only evaluated once. If an argument is NaN, the other argument is returned. If both arguments are NaN, NaN is returned. |
double fmax (double x, double y) | Function |
float fmaxf (float x, float y) | Function |
long double fmaxl (long double x, long double y) | Function |
The fmax function returns the greater of the two values x
and y.
If an argument is NaN, the other argument is returned. If both arguments are NaN, NaN is returned. |
double fdim (double x, double y) | Function |
float fdimf (float x, float y) | Function |
long double fdiml (long double x, long double y) | Function |
The fdim function returns the positive difference between
x and y. The positive difference is x -
y if x is greater than y, and 0 otherwise.
If x, y, or both are NaN, NaN is returned. |
double fma (double x, double y, double z) | Function |
float fmaf (float x, float y, float z) | Function |
long double fmal (long double x, long double y, long double z) | Function |
The fma function performs floating-point multiply-add. This is
the operation (x · y) + z, but the
intermediate result is not rounded to the destination type. This can
sometimes improve the precision of a calculation.
This function was introduced because some processors have a special
instruction to perform multiply-add. The C compiler cannot use it
directly, because the expression On processors which do not implement multiply-add in hardware,
|