Rounds to an integral value nearest to but not larger in magnitude than the argument.
#include <math.h> double trunc(double x); double truncf(double x); double truncl(double x);
x
The value to be truncated.
This function returns an argument to an integral value in floating-point format.
This facility may not be available on configurations of the EWL that run on platforms that do not have floating-point math capabilities.
#include <math.h> #include <stdio.h> int main(void) { double x = 2.4108; printf("trunc(%f) = %f\n", x, trunc(x)); return 0; } Output: trunc(2.410800) = 2.000000