Section: Linux Programmer's Manual (3)
Return to Main Contents
trunc, truncf, truncl - round to integer, towards zero
double trunc(double x);
float truncf(float x);
long double truncl(long double x);
Link with -lm.
Feature Test Macro Requirements for glibc (see
_XOPEN_SOURCE >= 600 || _ISOC99_SOURCE ||
_POSIX_C_SOURCE >= 200112L;
These functions round x to the nearest integer
not larger in absolute value.
These functions return the rounded integer value.
If x is integral, infinite, or NaN, x itself is returned.
No errors occur.
These functions first appeared in glibc in version 2.1.
The integral value returned by these functions may be too large
to store in an integer type
To avoid an overflow, which will produce undefined results,
an application should perform a range check on the returned value
before assigning it to an integer type.
This page is part of release 3.27 of the Linux
A description of the project,
and information about reporting bugs,
can be found at
- RETURN VALUE
- CONFORMING TO
- SEE ALSO
This document was created by
using the manual pages.