]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/trunc.3
man3/t-v.3: srcfix: Use a single-font-style macro for a single argument
[thirdparty/man-pages.git] / man3 / trunc.3
CommitLineData
fea681da
MK
1.\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>.
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da 24.\"
4b8c67d9 25.TH TRUNC 3 2017-09-15 "" "Linux Programmer's Manual"
fea681da 26.SH NAME
5fab2e7c 27trunc, truncf, truncl \- round to integer, toward zero
fea681da
MK
28.SH SYNOPSIS
29.nf
30.B #include <math.h>
68e4db0a 31.PP
fea681da 32.BI "double trunc(double " x );
fea681da 33.BI "float truncf(float " x );
fea681da
MK
34.BI "long double truncl(long double " x );
35.fi
68e4db0a 36.PP
cc4615cc 37Link with \fI\-lm\fP.
68e4db0a 38.PP
cc4615cc
MK
39.in -4n
40Feature Test Macro Requirements for glibc (see
41.BR feature_test_macros (7)):
42.in
68e4db0a 43.PP
cc4615cc
MK
44.ad l
45.BR trunc (),
46.BR truncf (),
47.BR truncl ():
5161d9e0 48.RS 4
e464f054 49_ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
5161d9e0
MK
50.RE
51.ad
fea681da 52.SH DESCRIPTION
022671eb
MK
53These functions round
54.I x
30a264ba
MK
55to the nearest integer value that is not larger in magnitude than
56.IR x .
47297adb 57.SH RETURN VALUE
35646edb 58These functions return the rounded integer value, in floating format.
847e0d88 59.PP
022671eb 60If
d8a86e74 61.I x
022671eb
MK
62is integral, infinite, or NaN,
63.I x
64itself is returned.
fea681da 65.SH ERRORS
f1ab30a7 66No errors occur.
f0d7ce1d
MK
67.SH VERSIONS
68These functions first appeared in glibc in version 2.1.
d265b8f2 69.SH ATTRIBUTES
7b389f3c
PH
70For an explanation of the terms used in this section, see
71.BR attributes (7).
72.TS
73allbox;
74lbw27 lb lb
75l l l.
76Interface Attribute Value
77T{
d265b8f2
PH
78.BR trunc (),
79.BR truncf (),
d265b8f2 80.BR truncl ()
7b389f3c
PH
81T} Thread safety MT-Safe
82.TE
47297adb 83.SH CONFORMING TO
9a74e018 84C99, POSIX.1-2001, POSIX.1-2008.
f1ab30a7
MK
85.SH NOTES
86The integral value returned by these functions may be too large
87to store in an integer type
88.RI ( int ,
89.IR long ,
90etc.).
91To avoid an overflow, which will produce undefined results,
92an application should perform a range check on the returned value
93before assigning it to an integer type.
47297adb 94.SH SEE ALSO
fea681da
MK
95.BR ceil (3),
96.BR floor (3),
97.BR lrint (3),
98.BR nearbyint (3),
99.BR rint (3),
100.BR round (3)