1TRUNC(3) Linux Programmer's Manual TRUNC(3)
2
3
4
6 trunc, truncf, truncl - round to integer, towards 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(): _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE; or
20 cc -std=c99
21
23 These functions round x to the nearest integer not larger in absolute
24 value.
25
27 These functions return the rounded integer value.
28
29 If x is integral, infinite, or NaN, x itself is returned.
30
32 No errors occur.
33
35 These functions first appeared in glibc in version 2.1.
36
38 C99, POSIX.1-2001.
39
41 The integral value returned by these functions may be too large to
42 store in an integer type (int, long, etc.). To avoid an overflow,
43 which will produce undefined results, an application should perform a
44 range check on the returned value before assigning it to an integer
45 type.
46
48 ceil(3), floor(3), lrint(3), nearbyint(3), rint(3), round(3)
49
51 This page is part of release 3.25 of the Linux man-pages project. A
52 description of the project, and information about reporting bugs, can
53 be found at http://www.kernel.org/doc/man-pages/.
54
55
56
57 2008-08-11 TRUNC(3)