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

[none]

_DOMAIN

floor には、SSE2 (Streaming SIMD Extensions 2) を使用する実装があります。 SSE2 実装の使用に関する情報と制限については、「_set_SSE2_enable」を参照してください。

解説

C++ ではオーバーロードが可能であるため、floor のオーバーロードを呼び出すことができます。 C プログラムでは、floor は常に倍精度浮動小数点数を受け取り、倍精度浮動小数点数を返します。

必要条件

機能

必須ヘッダー

floor, floorf

<math.h>

互換性の詳細については、「C ランタイム ライブラリ」の「互換性」を参照してください。

使用例

// 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 関数

System::Math::Floor

参照

参照

浮動小数点サポート

ceil、ceilf

fmod、fmodf