fmod, fmodf
Berechnet den Gleitkommarest.
double fmod(
double x,
double y
);
float fmod(
float x,
float y
); // C++ only
long double fmod(
long double x,
long double y
); // C++ only
float fmodf(
float x,
float y
);
Parameter
- x, y
Gleitkommawerte.
Rückgabewert
fmod gibt den Gleitkommarest von x / y zurück. Wenn der Wert von y 0,0 ist, gibt fmod ein stilles NaN zurück. Informationen zur Darstellung eines stillen nan durch die printf - Familie, finden Sie unter printf.
Hinweise
Die fmod-Funktion berechnet den Gleitkommarest f von x / y wie etwa x = i * y + f, wobei i eine ganze Zahl ist, f das gleiche Zeichen wie x hat und der absolute Wert von f kleiner ist als der absolute Wert von y.
C++ zulässig Überladen, sodass Sie Überladungen von fmod aufrufen. In einem C-Programm verwendet fmod immer zwei Double und gibt einen Double zurück.
Anforderungen
Funktion |
Erforderlicher Header |
---|---|
fmod, fmodf |
<math.h> |
Zusätzliche Informationen zur Kompatibilität finden Sie unter Kompatibilität in der Einführung.
Beispiel
// crt_fmod.c
// This program displays a floating-point remainder.
#include <math.h>
#include <stdio.h>
int main( void )
{
double w = -10.0, x = 3.0, z;
z = fmod( w, x );
printf( "The remainder of %.2f / %.2f is %f\n", w, x, z );
}