Chapter Contents

Previous

Next
trunc

trunc



Truncate to floating-point integer

Portability: C99


SYNOPSIS
DESCRIPTION
RETURN VALUE
IMPLEMENTATION
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

   #include <math.h>

   double trunc(double x);
   float truncf(float x);
   long double truncl(long double x);


DESCRIPTION

trunc converts its argument to an integral value, rounding towards zero, and returns it as a floating-point value.

The function name truncf should be used for float arguments, and truncl for long double arguments. Alternately, if the header file tgmath.h is included, trunc may be used with any numeric argument type.


RETURN VALUE

trunc returns its argument converted to an integer.


IMPLEMENTATION

trunc is implemented as a built-in function unless it is undefined by a #undef statement.


RELATED FUNCTIONS

ceil, floor, llrint, llround, lrint, lround, nearbyint, rint, round


SEE ALSO

"Mathematical Functions" in Chapter 2, "Function Categories"


Chapter Contents

Previous

Next

Top of Page

Copyright © 2004 by SAS Institute Inc., Cary, NC, USA. All rights reserved.