]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/trunc.3
round.3: ffix
[thirdparty/man-pages.git] / man3 / trunc.3
CommitLineData
fea681da
MK
1.\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>.
2.\"
3.\" Permission is granted to make and distribute verbatim copies of this
4.\" manual provided the copyright notice and this permission notice are
5.\" preserved on all copies.
6.\"
7.\" Permission is granted to copy and distribute modified versions of this
8.\" manual under the conditions for verbatim copying, provided that the
9.\" entire resulting derived work is distributed under the terms of a
10.\" permission notice identical to this one.
c13182ef 11.\"
fea681da
MK
12.\" Since the Linux kernel and libraries are constantly changing, this
13.\" manual page may be incorrect or out-of-date. The author(s) assume no
14.\" responsibility for errors or omissions, or for damages resulting from
15.\" the use of the information contained herein. The author(s) may not
16.\" have taken the same level of care in the production of this manual,
17.\" which is licensed free of charge, as they might when working
18.\" professionally.
c13182ef 19.\"
fea681da
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\"
f0d7ce1d 23.TH TRUNC 3 2008-08-11 "" "Linux Programmer's Manual"
fea681da
MK
24.SH NAME
25trunc, truncf, truncl \- round to integer, towards zero
26.SH SYNOPSIS
27.nf
28.B #include <math.h>
29.sp
30.BI "double trunc(double " x );
31.br
32.BI "float truncf(float " x );
33.br
34.BI "long double truncl(long double " x );
35.fi
36.sp
cc4615cc
MK
37Link with \fI\-lm\fP.
38.sp
39.in -4n
40Feature Test Macro Requirements for glibc (see
41.BR feature_test_macros (7)):
42.in
43.sp
44.ad l
45.BR trunc (),
46.BR truncf (),
47.BR truncl ():
5161d9e0
MK
48.RS 4
49_XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE
50.br
51or
cc4615cc 52.I cc\ -std=c99
5161d9e0
MK
53.RE
54.ad
fea681da
MK
55.SH DESCRIPTION
56These functions round \fIx\fP to the nearest integer
57not larger in absolute value.
58.SH "RETURN VALUE"
f1ab30a7
MK
59These functions return the rounded integer value.
60
61If \fIx\fP is integral, infinite, or NaN, \fIx\fP itself is returned.
fea681da 62.SH ERRORS
f1ab30a7 63No errors occur.
f0d7ce1d
MK
64.SH VERSIONS
65These functions first appeared in glibc in version 2.1.
fea681da 66.SH "CONFORMING TO"
f1ab30a7
MK
67C99, POSIX.1-2001.
68.SH NOTES
69The integral value returned by these functions may be too large
70to store in an integer type
71.RI ( int ,
72.IR long ,
73etc.).
74To avoid an overflow, which will produce undefined results,
75an application should perform a range check on the returned value
76before assigning it to an integer type.
fea681da
MK
77.SH "SEE ALSO"
78.BR ceil (3),
79.BR floor (3),
80.BR lrint (3),
81.BR nearbyint (3),
82.BR rint (3),
83.BR round (3)