Table of Content

Floor Function >> Round Down Value >> Math.h >> Header File in C



Floor Function :

  1. Floor() is also Called as “Round Down” 
  2. floorl Function Evaluates “floorl finds the largest (long double) integer not Greater than x.”
  3. Returns the largest integral value that is not greater than x.
  4. Suppose num = 12.1 then Floor(num) Returns 12
  5. 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 -4

Negative Parameter ???

  1. As Move Towards Positive Direction , we can conclude that –
5 > 4 > 3 > 2 > 1
  1. So floor(3.2) Returns ==> 3
  2. As Move Towards Negative Direction , we can conclude that –
-1 > -2 > -3 > -4 > -5
  1. So floor(-3.2) Returns ==> -4