Floor Function >> Round Down Value >> Math.h >> Header File in C
Floor Function :
- Floor() is also Called as “Round Down”
- floorl Function Evaluates “floorl finds the largest (long double) integer not Greater than x.”
- Returns the largest integral value that is not greater than x.
- Suppose num = 12.1 then Floor(num) Returns 12
- Header File : Math.h
Syntax :
double floor (double x);
float floor (float x);
long double floor (long double x);Live Example :
/* floor example */
#include<stdio.h>
#include<math.h>
int main ()
{
printf ("floor of 4.5 is %fn", floor(4.5));
printf ("floor of 6.1 is %fn", floor(6.1));
printf ("floor of -2.3 is %fn", floor(-2.3));
printf ("floor of -3.8 is %fn", floor(-3.8));
return 0;
}Output :
floor of 4.5 is 4
floor of 6.1 is 6
floor of -2.3 is -3
floor of -3.8 is -4Negative Parameter ???
- As Move Towards Positive Direction , we can conclude that -
5 > 4 > 3 > 2 > 1
- So floor(3.2) Returns ==> 3
- As Move Towards Negative Direction , we can conclude that -
-1 > -2 > -3 > -4 > -5
- So floor(-3.2) Returns ==> -4