Freigeben über


floor, floorf, floorl

Berechnet die nächstliegende nicht kleinere ganze Zahl eines Werts.

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
);

Parameter

  • x
    Gleitkommawert.

Rückgabewert

Die floor-Funktionen geben einen Gleitkommawert zurück, der die größte ganze Zahl darstellt, die kleiner oder gleich x ist. Es gibt keine Fehlerrückgabe.

Eingabe

SEH-Ausnahme

Matherr-Ausnahme

± QNAN,IND

Keine

_DOMAIN

floor ist eine Implementierung, die SIMD-Streamingerweiterungen 2 (SSE2) verwendet. Informationen und Einschränkungen zur Verwendung der SSE2-Implementierung finden Sie unter _set_SSE2_enable.

Hinweise

Da C++ das Überladen zulässt, können Sie Überladungen von floor aufrufen, die float- und long double-Werte verwenden und zurückgeben. In einem C-Programm verwendet floor immer double und gibt diesen Wert zurück.

Anforderungen

Funktion

Erforderlicher Header

floor, floorf, floorl

<math.h>

Zusätzliche Informationen zur Kompatibilität finden Sie unter Kompatibilität.

Beispiel

// 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-Entsprechung

System::Math::Floor

Siehe auch

Referenz

Gleitkommaunterstützung

ceil, ceilf, ceill

round, roundf, roundl

fmod, fmodf