1TRUNC(3) Linux Programmer's Manual TRUNC(3)
2
3
4
6 trunc, truncf, truncl - round to integer, toward zero
7
9 #include <math.h>
10
11 double trunc(double x);
12 float truncf(float x);
13 long double truncl(long double x);
14
15 Link with -lm.
16
17 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19 trunc(), truncf(), truncl():
20 _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE ||
21 _POSIX_C_SOURCE >= 200112L;
22 or cc -std=c99
23
25 These functions round x to the nearest integer not larger in absolute
26 value.
27
29 These functions return the rounded integer value.
30
31 If x is integral, infinite, or NaN, x itself is returned.
32
34 No errors occur.
35
37 These functions first appeared in glibc in version 2.1.
38
40 Multithreading (see pthreads(7))
41 The trunc(), truncf(), and truncl() functions are thread-safe.
42
44 C99, POSIX.1-2001.
45
47 The integral value returned by these functions may be too large to
48 store in an integer type (int, long, etc.). To avoid an overflow,
49 which will produce undefined results, an application should perform a
50 range check on the returned value before assigning it to an integer
51 type.
52
54 ceil(3), floor(3), lrint(3), nearbyint(3), rint(3), round(3)
55
57 This page is part of release 3.53 of the Linux man-pages project. A
58 description of the project, and information about reporting bugs, can
59 be found at http://www.kernel.org/doc/man-pages/.
60
61
62
63 2013-06-21 TRUNC(3)