Trusted answers to developer questions

Samia Ishaque

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The ** fminf()** function in C determines the minimum of two floating-point numbers. The function is defined in the

`<math.h>`

header file.To use the `fminf()`

function, you need to include the `<math.h>`

library at the beginning of your program. Below is an example of how you can do this:

```
#include<math.h>
```

The `fminf()`

function in C is defined in the `<math.h>`

header file as shown below:

```
float fminf( float x, float y );
```

The `fminf()`

function takes two arguments ($x$ and $y$) of type `float`

as input.

Upon successful executive, the `fminf()`

function returns the minimum of the two numbers. The return type is also `float`

.

On the other hand, varying $x$ and $y$ values changes the results for `fminf()`

in the following ways:

- If both inputs are
`Not a Number NaN`

, the return value is also`NaN`

. - If $x$ is
`NaN`

,`fminf()`

will return $y$, and vice versa.

Below is an example of how to use `fminf()`

function, given that $x$ and $y$ are $3.2$ and $2.5$ respectively. The `fminf()`

function returns the smaller floating point number, which in this case is $2.5$.

#include<stdio.h> #include<math.h> int main() { float smallest = fminf(3.2, 2.5); printf("The smaller of the two numbers is: %f\n", smallest); return 0; }

The code below demonstrates how varying $x$ and $y$ values affect the return value of the `fminf()`

function:

#include<stdio.h> #include<math.h> int main() { float min1 = fminf(NAN, 2.5); printf("The smaller of the two numbers is: %f\n", min1); float min2 = fminf(NAN, NAN); printf("The smaller of the two numbers is: %f\n", min2); return 0; }

RELATED TAGS

c

CONTRIBUTOR

Samia Ishaque

Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring

Related Courses