C trunc function truncates value of arg

Syntax

C trunc function has the following syntax.

  • float truncf(float arg);
  • double trunc(double arg);
  • long double truncl(long double arg);

C trunc functions are from header file math.h.

Description

C trunc functions return the truncated value of arg.

Example

Truncate value of argument by using C trunc function.


#include <math.h>
#include <stdio.h>
//  w w  w.j  a  v  a  2 s  . c om
int main(void)
{
  printf("%f\n", trunc (1.2));

  return 0;
}

The code above generates the following result.





















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h