当前位置: C语言 -- 标准库 -- <math.h> -- floorf

floorf函数


概要:
#include <math.h>
float floorf(float x);

描述:

该函数计算不大于参数x的最大整数值。


参数:
float x

参数为一个float类型的浮点数。


返回值:

函数返回浮点数形式表示的x值。


范例:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
/*函数floorf范例*/

#include <math.h>
#include <stdio.h>

int main(void)
{
    float x = 2.3f;
    float y;

    y = floorf(x);
    printf("The largest integer value not greater than %.6f is %.6f.\n", x, y);

    return 0;
}

输出:

The largest integer value not greater than 2.300000 is 2.000000.


相关内容:
floor double类型的向下取整函数。
floorl long double类型的向下取整函数。