標準/拡張機能 | C/C++ | 依存項目 |
---|---|---|
ISO C |
両方 |
#include <math.h>
double floor(double x);
float floor(float x); /* C++ only */
long double floor(long double x); /* C++ only */
float floorf(float x);
long double floorl(long double x);
double、浮動、または long double の値として表された整数の計算値を戻します。結果は範囲エラーにはなりません。
⁄* CELEBF24
This example assigns y the value of the largest integer that is less
than or equal to 2.8, and it assigns z the value of the largest integer
that is less than or equal to -2.8.
*⁄
#include <math.h>
#include <stdio.h>
int main(void)
{
double y, z;
y = floor(2.8);
z = floor(-2.8);
printf("floor( 2.8 ) = %f¥n", y);
printf("floor( -2.8 ) = %f¥n", z);
}
floor( 2.8 ) = 2.000000
floor( -2.8 ) = -3.000000