1trunc(3)                   Library Functions Manual                   trunc(3)
2
3
4

NAME

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

LIBRARY

9       Math library (libm, -lm)
10

SYNOPSIS

12       #include <math.h>
13
14       double trunc(double x);
15       float truncf(float x);
16       long double truncl(long double x);
17
18   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20       trunc(), truncf(), truncl():
21           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
22

DESCRIPTION

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

RETURN VALUE

28       These functions return the rounded integer value, in floating format.
29
30       If x is integral, infinite, or NaN, x itself is returned.
31

ERRORS

33       No errors occur.
34

ATTRIBUTES

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

STANDARDS

46       C11, POSIX.1-2008.
47

HISTORY

49       glibc 2.1.  C99, POSIX.1-2001.
50

NOTES

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

SEE ALSO

59       ceil(3), floor(3), lrint(3), nearbyint(3), rint(3), round(3)
60
61
62
63Linux man-pages 6.04              2023-03-30                          trunc(3)
Impressum