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 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
21
23 These functions round x to the nearest integer value that is not larger
24 in magnitude than x.
25
27 These functions return the rounded integer value, in floating format.
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 For an explanation of the terms used in this section, see
39 attributes(7).
40
41 ┌────────────────────────────┬───────────────┬─────────┐
42 │Interface │ Attribute │ Value │
43 ├────────────────────────────┼───────────────┼─────────┤
44 │trunc(), truncf(), truncl() │ Thread safety │ MT-Safe │
45 └────────────────────────────┴───────────────┴─────────┘
47 C99, POSIX.1-2001, POSIX.1-2008.
48
50 The integral value returned by these functions may be too large to
51 store in an integer type (int, long, etc.). To avoid an overflow,
52 which will produce undefined results, an application should perform a
53 range check on the returned value before assigning it to an integer
54 type.
55
57 ceil(3), floor(3), lrint(3), nearbyint(3), rint(3), round(3)
58
60 This page is part of release 5.02 of the Linux man-pages project. A
61 description of the project, information about reporting bugs, and the
62 latest version of this page, can be found at
63 https://www.kernel.org/doc/man-pages/.
64
65
66
67 2019-03-06 TRUNC(3)