Calocybe: Auf- und abrunden

Beitrag lesen

Hi Tom!

Und was sagt mir das als _Nicht_ c-Programmierer bezüglich Funktionsparameter, Rückgabewert und Funktionsweise ???

<CITE SOURCE="Microsoft Visual C++ 5.0 Runtime Library Reference">
    double floor(double x);
    Calculates the floor of a value.

Function    Required Header     Compatibility
    floor       <math.h>            ANSI, Win 95, Win NT

Return Value

The floor function returns a floating-point value representing the largest integer that is less than or equal to x. There is no error return.

Parameter

x Floating-point value

Example

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

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

Output

The floor of 2.8 is 2.000000
    The floor of -2.8 is -3.000000
    The ceil of 2.8 is 3.000000
    The ceil of -2.8 is -2.000000

See Also ceil, fmod
</CITE>

Ist zwar eine Microsoft-Beschreibung, da als "Compatibility" jedoch ANSI angegeben ist, sollte die Bibliothek bei jedem Ansi-kompatiblen C genauso funktionieren.

Calocybe