What is floorf() in C?

floorf() in C is used to calculate the largest integer value not greater than the argument value. floorf() is defined in the math.h header file and the function declaration is as follows:

float floorf(float arg);

Parameters and return value

arg: floating point value

Return value: largest integer value not greater than arg

Example program

#include <math.h>
#include <stdio.h>
int main(void)
{
printf("floor(+3.0) = %.1f\n", floorf(3.0));
printf("floor(+3.9) = %.1f\n", floorf(3.9));
printf("floor(-3.9) = %.1f\n", floorf(-3.9));
printf("floor(-0.0) = %.1f\n", floorf(-0.0));
printf("floor(0.0) = %.1f\n", floorf(0.0));
/* special cases */
printf("floor(inf) = %.1f\n", floorf(INFINITY));
printf("floor(-inf) = %.1f\n", floorf(-INFINITY));
printf("floorf = %f\n", floorf(NAN));
return 0;
}

Explanation

First, we import the math.h header file from the C standard library. The program then simply prints the output of floorf() on possible example values.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved