====== floor() ====== floor ist definiert in der ''[[start|math]]'', die in C über ''math.h'', bzw. in C++ über ''cmath'' eingebunden wird. ===== Funktion ===== floor() rundet den übergebenen Fließkommawert auf die nächst kleinere natürliche Zahl. Die Nachkommastellen werden gewissermaßen weggelassen. Zurückgegeben wird ebenfalls als Fließkommazahl. ===== Signatur ===== #include double floor( double x ); float floor( float x ); long double floor( long double x ); **x**: der abzurundende Wert **Return value**: Der zur nächst kleineren natürlichen Zahl abgerundete Wert. ===== Fehlerquellen ===== - ===== Beispiel ===== #include // für EXIT_SUCCESS #include // für floor #include // für printf() int main( void ) { printf( "floor( 1.1 ) : %f\n", floor( 1.1 ) ); printf( "floor( 1.9 ) : %f\n", floor( 1.9 ) ); printf( "floor( -1.1 ) : %f\n", floor( -1.1 ) ); printf( "floor( -1.9 ) : %f\n", floor( -1.9 ) ); return EXIT_SUCCESS; } Ausgabe: floor( 1.1 ) : 1.0 floor( 1.9 ) : 1.0 floor( -1.1 ) : -2.0 floor( -1.9 ) : -2.0 ===== siehe auch ===== [[c:lib:math:start|math]]: [[c:lib:math:ceil()]], [[c:lib:math:fabs()]], [[c:lib:math:modf()]]