C examples for math.h:floor
function
<cmath> <ctgmath> <math.h>
Rounds x downward, returning the largest integral value that is not greater than x.
long double floorl (long double x); long double floor (long double x); double floor (double x); float floorf (float x); float floor (float x); double floor (T x);
Parameter | Description |
---|---|
x | Value to round down. |
The value of x rounded downward (as a floating-point value).
#include <stdio.h> #include <math.h> /* floor */ int main ()/*from w w w . j av a2s.c o m*/ { printf ( "%.1lf\n", floor (2.1) ); printf ( "%.1lf\n", floor (3.9) ); printf ( "%.1lf\n", floor (-2.1) ); printf ( "%.1lf\n", floor (-3.9) ); return 0; }