fmin, fminf, fminl
From cppreference.com
C
Concurrency support (C11)
Common mathematical functions
Functions
Basic operations
Maximum/minimum operations
(C23)
(C23)
(C23)
(C23)
(C23)
Exponential functions
Power functions
Trigonometric and hyperbolic functions
Nearest integer floating-point
Floating-point manipulation
Narrowing operations
Quantum and quantum exponent
(C23)
(C23)
(C23)
(C23)
Decimal re-encoding functions
(C23)
(C23)
(C23)
(C23)
Total order and payload functions
(C23)
(C23)
(C23)
(C23)
Classification
(C99)
(C23)
(C99)
(C99)
(C99)
(C99)
(C99)
(C23)
(C23)
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)
(C23)
(C23)
Error and gamma functions
Types
(C99)(C99)
(C99)(C99)
(C23)(C23)
Macro constants
Special floating-point values
(C99)(C99)(C23)
(C99)(C23)
(C99)(C23)
Arguments and return values
(C99)(C99)
(C99)(C99)(C99)(C99)(C99)
(C23)(C23)
(C23)(C23)(C23)(C23)(C23)
Error handling
(C99)(C99)
(C99)
Fast operation indicators
(C99)(C99)
(C23)(C23)(C23)(C23)
(C23)(C23)(C23)(C23)
(C23)(C23)(C23)(C23)
(C99)(C23)
(C23)(C23)(C23)(C23)
(C23)(C23)(C23)(C23)
(C23)(C23)(C23)(C23)
Defined in header
<math.h>
float fminf( float x, float y );
(1)
(since C99)
double fmin( double x, double y );
(2)
(since C99)
long double fminl( long double x, long double y );
(3)
(since C99)
Defined in header
<tgmath.h>
#define fmin( x, y )
(4)
(since C99)
1-3) Returns the smaller of two floating-point arguments, treating NaNs as missing data (between a NaN and a numeric value, the numeric value is chosen).
4) Type-generic macro: If any argument has type long double,
fminl
is called. Otherwise, if any argument has integer type or has type double, fmin
is called. Otherwise, fminf
is called.[edit] Parameters
x, y
-
floating-point values
[edit] Return value
If successful, returns the smaller of two floating-point values. The value returned is exact and does not depend on any rounding modes.
[edit] Error handling
This function is not subject to any of the error conditions specified in math_errhandling
.
If the implementation supports IEEE floating-point arithmetic (IEC 60559),
- If one of the two arguments is NaN, the value of the other argument is returned
- Only if both arguments are NaN, NaN is returned
[edit] Notes
This function is not required to be sensitive to the sign of zero, although some implementations additionally enforce that if one argument is +0 and the other is -0, then -0 is returned.
[edit] Example
Run this code
Possible output:
fmin(2,1) = 1.000000 fmin(-Inf,0) = -inf fmin(NaN,-1) = -1.000000
[edit] References
- C23 standard (ISO/IEC 9899:2024):
- 7.12.12.3 The fmin functions (p: TBD)
- 7.25 Type-generic math <tgmath.h> (p: TBD)
- F.10.9.3 The fmin functions (p: TBD)
- C17 standard (ISO/IEC 9899:2018):
- 7.12.12.3 The fmin functions (p: TBD)
- 7.25 Type-generic math <tgmath.h> (p: TBD)
- F.10.9.3 The fmin functions (p: TBD)
- C11 standard (ISO/IEC 9899:2011):
- 7.12.12.3 The fmin functions (p: 258)
- 7.25 Type-generic math <tgmath.h> (p: 373-375)
- F.10.9.3 The fmin functions (p: 530)
- C99 standard (ISO/IEC 9899:1999):
- 7.12.12.3 The fmin functions (p: 239)
- 7.22 Type-generic math <tgmath.h> (p: 335-337)
- F.9.9.3 The fmin functions (p: 466)
[edit] See also
C++ documentation for fmin