Inhaltsverzeichnis

modf()

#include <cmath>

double modf (double x, double *ganzzahl) 

Spaltet ganzzahl von x ab und liefert den Nachkommaanteil.

Parameter

x Fließkommazahl
ganzzahl Zeiger auf Fließkommavariable

Ergebnis

Rückgabewert: x - *ganzzahl. Beide Teile erhalten dasselbe Vorzeichen wie x.

Siehe auch

fmod().

Beispiel

modf.cpp
#include <cmath>
#include <iostream>
 
int main()
{
  double x = 123.45, vorzahl, nachkomma;
 
  nachkomma = std::modf(x, &vorzahl);
 
  std::cout << x << " = " << vorzahl << " + " << nachkomma << '\n';
}