What is fminl in C?

The fminl function is defined in the <tgmath.h> header file in C. It takes in two parameters of type long double: x and y. It then returns the smaller of the two numbers.

The illustration below shows how the fminl function works:

How does fminl work?

Declaration

The fminl function is defined as follows:

long double fminl( long double x, long double y );

Parameters

The fminl function takes two values of the long double type as parameters.

Return value

The fminl function returns the smaller of the two long double values.

Error handling

The fminl function returns special values for certain arguments:

x y Returned Value
valid long double NaN x
NaN valid long double y
NaN NaN Nan

Example

The following code snippet shows how we can use the fminl function:

#include <stdio.h> // include header for printf
#include <tgmath.h> // include header for fminl
int main(){
// setting values for x and y
long double x = 2.0;
long double y = 4.0;
long double result;
result = fminl(x, y);
printf("The result is: %Lf", result);
return 0;
}
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved