1TRUNC(3)                   Linux Programmer's Manual                  TRUNC(3)
2
3
4

NAME

6       trunc, truncf, truncl - round to integer, toward zero
7

SYNOPSIS

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

DESCRIPTION

23       These functions round x to the nearest integer value that is not larger
24       in magnitude than x.
25

RETURN VALUE

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

ERRORS

32       No errors occur.
33

VERSIONS

35       These functions first appeared in glibc in version 2.1.
36

ATTRIBUTES

38       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
39       tributes(7).
40
41       ┌────────────────────────────────────────────┬───────────────┬─────────┐
42Interface                                   Attribute     Value   
43       ├────────────────────────────────────────────┼───────────────┼─────────┤
44trunc(), truncf(), truncl()                 │ Thread safety │ MT-Safe │
45       └────────────────────────────────────────────┴───────────────┴─────────┘
46

CONFORMING TO

48       C99, POSIX.1-2001, POSIX.1-2008.
49

NOTES

51       The  integral  value  returned  by  these functions may be too large to
52       store in an integer type (int, long,  etc.).   To  avoid  an  overflow,
53       which  will  produce undefined results, an application should perform a
54       range check on the returned value before assigning  it  to  an  integer
55       type.
56

SEE ALSO

58       ceil(3), floor(3), lrint(3), nearbyint(3), rint(3), round(3)
59

COLOPHON

61       This  page  is  part of release 5.13 of the Linux man-pages project.  A
62       description of the project, information about reporting bugs,  and  the
63       latest     version     of     this    page,    can    be    found    at
64       https://www.kernel.org/doc/man-pages/.
65
66
67
68                                  2021-03-22                          TRUNC(3)
Impressum