Namespaces
Variants
Views
Actions

floor

From cppreference.com
< c‎ | numeric‎ | math
Revision as of 05:07, 1 April 2013 by Jbenshetler (Talk | contribs)

 
 
 
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)(C99)(C99)
Exponential functions
(C99)
(C99)
(C99)
(C99)
Power functions
(C99)
(C99)
Trigonometric and hyperbolic functions
(C99)
(C99)
(C99)
Error and gamma functions
(C99)
(C99)
(C99)
(C99)
Nearest integer floating point operations
floor
(C99)(C99)(C99)
(C99)
(C99)(C99)(C99)
Floating point manipulation functions
(C99)(C99)
(C99)
(C99)
Classification
(C99)
(C99)
(C99)
Macro constants
 

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <math.h>
</td>

<td></td> <td></td> <tr class="t-dcl ">

<td >
float       floorf( float arg );
</td>

<td class="t-dcl-nopad"> </td> <td > (since C99) </td> </tr> <tr class="t-dcl ">

<td class="t-dcl-nopad">
double      floor( double arg );
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">

<td >
long double floorl( long double arg );
</td>

<td class="t-dcl-nopad"> </td> <td > (since C99) </td> </tr> Template:ddcl list end

Computes nearest integer not greater than arg.

Contents

Parameters

arg - floating point value

Return value

Nearest integer not greater than arg

Notes

The integer value can be always represented by the given floating point type.

Example

#include <stdio.h>
#include <math.h>
 
void report_floorf(float f) {
	printf("floorf(%5.2f)=%5.2f\n",f,floorf(f));
} /* end report_floorf() */
 
void demo_floorf() {
	report_floorf(9.1f);
	report_floorf(-9.1f);
	report_floorf(0.0f);
} /* end demo_floorf() */

Output:

floorf( 9.10)= 9.00
floorf(-9.10)=-10.00
floorf( 0.00)= 0.00

See also

Template:c/numeric/math/dcl list ceilTemplate:c/numeric/math/dcl list truncTemplate:c/numeric/math/dcl list round