Previous: Floating-Point Comparison Functions, Up: Arithmetic Functions [Contents][Index]

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.

- Function:
*double***fmin***(double*¶`x`, double`y`) - Function:
*float***fminf***(float*¶`x`, float`y`) - Function:
*long double***fminl***(long double*¶`x`, long double`y`) - Function:
*_FloatN***fminfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatNx***fminfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

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 a quiet NaN, the other argument is returned. If both arguments are NaN, or either is a signaling NaN, NaN is returned.

- Function:
*double***fmax***(double*¶`x`, double`y`) - Function:
*float***fmaxf***(float*¶`x`, float`y`) - Function:
*long double***fmaxl***(long double*¶`x`, long double`y`) - Function:
*_FloatN***fmaxfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatNx***fmaxfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

The

`fmax`

function returns the greater of the two values`x`and`y`.If an argument is a quiet NaN, the other argument is returned. If both arguments are NaN, or either is a signaling NaN, NaN is returned.

- Function:
*double***fminimum***(double*¶`x`, double`y`) - Function:
*float***fminimumf***(float*¶`x`, float`y`) - Function:
*long double***fminimuml***(long double*¶`x`, long double`y`) - Function:
*_FloatN***fminimumfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatNx***fminimumfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

The

`fminimum`

function returns the lesser of the two values`x`and`y`. Unlike`fmin`

, if either argument is a NaN, NaN is returned. Positive zero is treated as greater than negative zero.

- Function:
*double***fmaximum***(double*¶`x`, double`y`) - Function:
*float***fmaximumf***(float*¶`x`, float`y`) - Function:
*long double***fmaximuml***(long double*¶`x`, long double`y`) - Function:
*_FloatN***fmaximumfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatNx***fmaximumfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

The

`fmaximum`

function returns the greater of the two values`x`and`y`. Unlike`fmax`

, if either argument is a NaN, NaN is returned. Positive zero is treated as greater than negative zero.

- Function:
*double***fminimum_num***(double*¶`x`, double`y`) - Function:
*float***fminimum_numf***(float*¶`x`, float`y`) - Function:
*long double***fminimum_numl***(long double*¶`x`, long double`y`) - Function:
*_FloatN***fminimum_numfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatNx***fminimum_numfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

The

`fminimum_num`

function returns the lesser of the two values`x`and`y`. If one argument is a number and the other is a NaN, even a signaling NaN, the number is returned. Positive zero is treated as greater than negative zero.

- Function:
*double***fmaximum_num***(double*¶`x`, double`y`) - Function:
*float***fmaximum_numf***(float*¶`x`, float`y`) - Function:
*long double***fmaximum_numl***(long double*¶`x`, long double`y`) - Function:
*_FloatN***fmaximum_numfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatNx***fmaximum_numfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

The

`fmaximum_num`

function returns the greater of the two values`x`and`y`. If one argument is a number and the other is a NaN, even a signaling NaN, the number is returned. Positive zero is treated as greater than negative zero.

- Function:
*double***fminmag***(double*¶`x`, double`y`) - Function:
*float***fminmagf***(float*¶`x`, float`y`) - Function:
*long double***fminmagl***(long double*¶`x`, long double`y`) - Function:
*_FloatN***fminmagfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatNx***fminmagfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

These functions, from TS 18661-1:2014 and TS 18661-3:2015, return whichever of the two values

`x`and`y`has the smaller absolute value. If both have the same absolute value, or either is NaN, they behave the same as the`fmin`

functions.

- Function:
*double***fmaxmag***(double*¶`x`, double`y`) - Function:
*float***fmaxmagf***(float*¶`x`, float`y`) - Function:
*long double***fmaxmagl***(long double*¶`x`, long double`y`) - Function:
*_FloatN***fmaxmagfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatNx***fmaxmagfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

These functions, from TS 18661-1:2014, return whichever of the two values

`x`and`y`has the greater absolute value. If both have the same absolute value, or either is NaN, they behave the same as the`fmax`

functions.

- Function:
*double***fminimum_mag***(double*¶`x`, double`y`) - Function:
*float***fminimum_magf***(float*¶`x`, float`y`) - Function:
*long double***fminimum_magl***(long double*¶`x`, long double`y`) - Function:
*_FloatN***fminimum_magfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatNx***fminimum_magfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

These functions return whichever of the two values

`x`and`y`has the smaller absolute value. If both have the same absolute value, or either is NaN, they behave the same as the`fminimum`

functions.

- Function:
*double***fmaximum_mag***(double*¶`x`, double`y`) - Function:
*float***fmaximum_magf***(float*¶`x`, float`y`) - Function:
*long double***fmaximum_magl***(long double*¶`x`, long double`y`) - Function:
*_FloatN***fmaximum_magfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatNx***fmaximum_magfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

These functions return whichever of the two values

`x`and`y`has the greater absolute value. If both have the same absolute value, or either is NaN, they behave the same as the`fmaximum`

functions.

- Function:
*double***fminimum_mag_num***(double*¶`x`, double`y`) - Function:
*float***fminimum_mag_numf***(float*¶`x`, float`y`) - Function:
*long double***fminimum_mag_numl***(long double*¶`x`, long double`y`) - Function:
*_FloatN***fminimum_mag_numfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatNx***fminimum_mag_numfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

These functions return whichever of the two values

`x`and`y`has the smaller absolute value. If both have the same absolute value, or either is NaN, they behave the same as the`fminimum_num`

functions.

- Function:
*double***fmaximum_mag_num***(double*¶`x`, double`y`) - Function:
*float***fmaximum_mag_numf***(float*¶`x`, float`y`) - Function:
*long double***fmaximum_mag_numl***(long double*¶`x`, long double`y`) - Function:
*_FloatN***fmaximum_mag_numfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatNx***fmaximum_mag_numfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

These functions return whichever of the two values

`x`and`y`has the greater absolute value. If both have the same absolute value, or either is NaN, they behave the same as the`fmaximum_num`

functions.

- Function:
*double***fdim***(double*¶`x`, double`y`) - Function:
*float***fdimf***(float*¶`x`, float`y`) - Function:
*long double***fdiml***(long double*¶`x`, long double`y`) - Function:
*_FloatN***fdimfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatNx***fdimfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

The

`fdim`

function returns the positive difference between`x`and`y`. The positive difference isif`x`-`y``x`is greater than`y`, and*0*otherwise.If

`x`,`y`, or both are NaN, NaN is returned.

- Function:
*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:
*_FloatN***fmafN***(_Float*¶`N``x`, _Float`N``y`, _Float`N``z`) - Function:
*_FloatNx***fmafNx***(_Float*¶`N`x`x`, _Float`N`x`y`, _Float`N`x`z`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

The

`fma`

function performs floating-point multiply-add. This is the operation*(*, but the intermediate result is not rounded to the destination type. This can sometimes improve the precision of a calculation.`x`·`y`) +`z`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 ‘

`x*y + z`’ is defined to round the intermediate result.`fma`

lets you choose when you want to round only once.On processors which do not implement multiply-add in hardware,

`fma`

can be very slow since it must avoid intermediate rounding.`math.h`defines the symbols`FP_FAST_FMA`

,`FP_FAST_FMAF`

, and`FP_FAST_FMAL`

when the corresponding version of`fma`

is no slower than the expression ‘`x*y + z`’. In the GNU C Library, this always means the operation is implemented in hardware.

- Function:
*float***fadd***(double*¶`x`, double`y`) - Function:
*float***faddl***(long double*¶`x`, long double`y`) - Function:
*double***daddl***(long double*¶`x`, long double`y`) - Function:
*_FloatM***fMaddfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatM***fMaddfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) - Function:
*_FloatMx***fMxaddfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatMx***fMxaddfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

These functions, from TS 18661-1:2014 and TS 18661-3:2015, return

, rounded once to the return type of the function without any intermediate rounding to the type of the arguments.`x`+`y`

- Function:
*float***fsub***(double*¶`x`, double`y`) - Function:
*float***fsubl***(long double*¶`x`, long double`y`) - Function:
*double***dsubl***(long double*¶`x`, long double`y`) - Function:
*_FloatM***fMsubfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatM***fMsubfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) - Function:
*_FloatMx***fMxsubfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatMx***fMxsubfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

These functions, from TS 18661-1:2014 and TS 18661-3:2015, return

, rounded once to the return type of the function without any intermediate rounding to the type of the arguments.`x`-`y`

- Function:
*float***fmul***(double*¶`x`, double`y`) - Function:
*float***fmull***(long double*¶`x`, long double`y`) - Function:
*double***dmull***(long double*¶`x`, long double`y`) - Function:
*_FloatM***fMmulfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatM***fMmulfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) - Function:
*_FloatMx***fMxmulfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatMx***fMxmulfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

These functions, from TS 18661-1:2014 and TS 18661-3:2015, return

, rounded once to the return type of the function without any intermediate rounding to the type of the arguments.`x`*`y`

- Function:
*float***fdiv***(double*¶`x`, double`y`) - Function:
*float***fdivl***(long double*¶`x`, long double`y`) - Function:
*double***ddivl***(long double*¶`x`, long double`y`) - Function:
*_FloatM***fMdivfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatM***fMdivfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) - Function:
*_FloatMx***fMxdivfN***(_Float*¶`N``x`, _Float`N``y`) - Function:
*_FloatMx***fMxdivfNx***(_Float*¶`N`x`x`, _Float`N`x`y`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

These functions, from TS 18661-1:2014 and TS 18661-3:2015, return

, rounded once to the return type of the function without any intermediate rounding to the type of the arguments.`x`/`y`

- Function:
*float***fsqrt***(double*¶`x`) - Function:
*float***fsqrtl***(long double*¶`x`) - Function:
*double***dsqrtl***(long double*¶`x`) - Function:
*_FloatM***fMsqrtfN***(_Float*¶`N``x`) - Function:
*_FloatM***fMsqrtfNx***(_Float*¶`N`x`x`) - Function:
*_FloatMx***fMxsqrtfN***(_Float*¶`N``x`) - Function:
*_FloatMx***fMxsqrtfNx***(_Float*¶`N`x`x`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

These functions, from TS 18661-1:2014 and TS 18661-3:2015, return the square root of

`x`, rounded once to the return type of the function without any intermediate rounding to the type of the arguments.

- Function:
*float***ffma***(double*¶`x`, double`y`, double`z`) - Function:
*float***ffmal***(long double*¶`x`, long double`y`, long double`z`) - Function:
*double***dfmal***(long double*¶`x`, long double`y`, long double`z`) - Function:
*_FloatM***fMfmafN***(_Float*¶`N``x`, _Float`N``y`, _Float`N``z`) - Function:
*_FloatM***fMfmafNx***(_Float*¶`N`x`x`, _Float`N`x`y`, _Float`N`x`z`) - Function:
*_FloatMx***fMxfmafN***(_Float*¶`N``x`, _Float`N``y`, _Float`N``z`) - Function:
*_FloatMx***fMxfmafNx***(_Float*¶`N`x`x`, _Float`N`x`y`, _Float`N`x`z`) -
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

These functions, from TS 18661-1:2014 and TS 18661-3:2015, return

*(*, rounded once to the return type of the function without any intermediate rounding to the type of the arguments and without any intermediate rounding of result of the multiplication.`x`·`y`) +`z`

Previous: Floating-Point Comparison Functions, Up: Arithmetic Functions [Contents][Index]