Inhaltsverzeichnis

trunc()

#include <cmath>

double trunc (double x) 

Schneidet den Nachkommaanteil der Zahl x ab (rundet zu Null hin).

Parameter

x Gleitkommazahl

Ergebnis

Rückgabewert: ganzzahliger Anteil der Zahl x.

Siehe auch

ceil(), floor(), nearbyint(), rint(), round().

Beispiel

trunc.cpp
#include <cmath>
#include <iostream>
 
int main()
{
  double x = 12.345;
  std::cout << std::trunc(x) << '\n';
}