]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/trunc.3
These functions first appeared in glibc 2.1.
[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.\"
a1949252 23.TH TRUNC 3 2008-08-05 "" "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 ():
48_XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE; or
49.I cc\ -std=c99
50.ad b
fea681da
MK
51.SH DESCRIPTION
52These functions round \fIx\fP to the nearest integer
53not larger in absolute value.
54.SH "RETURN VALUE"
f1ab30a7
MK
55These functions return the rounded integer value.
56
57If \fIx\fP is integral, infinite, or NaN, \fIx\fP itself is returned.
fea681da 58.SH ERRORS
f1ab30a7 59No errors occur.
fea681da 60.SH "CONFORMING TO"
f1ab30a7
MK
61C99, POSIX.1-2001.
62.SH NOTES
63The integral value returned by these functions may be too large
64to store in an integer type
65.RI ( int ,
66.IR long ,
67etc.).
68To avoid an overflow, which will produce undefined results,
69an application should perform a range check on the returned value
70before assigning it to an integer type.
fea681da
MK
71.SH "SEE ALSO"
72.BR ceil (3),
73.BR floor (3),
74.BR lrint (3),
75.BR nearbyint (3),
76.BR rint (3),
77.BR round (3)