floor, floorf

计算值的下限。

double floor(
   double x
);
float floor(
   float x 
); // C++ only
long double floor(
   long double x
); // C++ only
float floorf(
   float x
);

参数

  • x
    浮点值。

返回值

floor 函数返回表示小于或等于 x的最大整数的浮点值。 无错误返回。

输入

SEH 异常

Matherr 异常

± QNAN, IND

_DOMAIN

floor 具有使用流 SIMD 扩展 2 的实现 (SSE2)。 请参见 _set_SSE2_enable 信息和使用限制这次将实现。

备注

C++ 允许重载,因此,您可以调用 floor重载。 在 c. 程序, floor 始终采用并返回二进制文件。

要求

功能

必需的头

floor, floorf

math.h

有关其他的兼容性信息,请参见中介绍的 兼容性

示例

// crt_floor.c
// This example displays the largest integers
// less than or equal to the floating-point values 2.8
// and -2.8. It then shows the smallest integers greater
// than or equal to 2.8 and -2.8.


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

int main( void )
{
   double y;

   y = floor( 2.8 );
   printf( "The floor of 2.8 is %f\n", y );
   y = floor( -2.8 );
   printf( "The floor of -2.8 is %f\n", y );

   y = ceil( 2.8 );
   printf( "The ceil of 2.8 is %f\n", y );
   y = ceil( -2.8 );
   printf( "The ceil of -2.8 is %f\n", y );
}
  

.NET Framework 等效项

系统:: 算术:: floor

请参见

参考

浮点支持

ceil, ceilf

fmod, fmodf