trunc()

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);    
Parameter

x

The value to be truncated.

Remarks

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.

Listing: Example of trunc() Usage

#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