]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>. |
2 | .\" | |
5fbde956 | 3 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
fea681da | 4 | .\" |
1ae6b2c7 | 5 | .TH TRUNC 3 2021-03-22 GNU "Linux Programmer's Manual" |
fea681da | 6 | .SH NAME |
5fab2e7c | 7 | trunc, truncf, truncl \- round to integer, toward zero |
dacc8b97 AC |
8 | .SH LIBRARY |
9 | Math library | |
8fc3b2cf | 10 | .RI ( libm ", " \-lm ) |
fea681da MK |
11 | .SH SYNOPSIS |
12 | .nf | |
13 | .B #include <math.h> | |
68e4db0a | 14 | .PP |
fea681da | 15 | .BI "double trunc(double " x ); |
fea681da | 16 | .BI "float truncf(float " x ); |
fea681da MK |
17 | .BI "long double truncl(long double " x ); |
18 | .fi | |
68e4db0a | 19 | .PP |
d39ad78f | 20 | .RS -4 |
cc4615cc MK |
21 | Feature Test Macro Requirements for glibc (see |
22 | .BR feature_test_macros (7)): | |
d39ad78f | 23 | .RE |
68e4db0a | 24 | .PP |
cc4615cc MK |
25 | .BR trunc (), |
26 | .BR truncf (), | |
27 | .BR truncl (): | |
9d2adbae | 28 | .nf |
5c10d2c5 | 29 | _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
9d2adbae | 30 | .fi |
fea681da | 31 | .SH DESCRIPTION |
022671eb MK |
32 | These functions round |
33 | .I x | |
30a264ba MK |
34 | to the nearest integer value that is not larger in magnitude than |
35 | .IR x . | |
47297adb | 36 | .SH RETURN VALUE |
35646edb | 37 | These functions return the rounded integer value, in floating format. |
847e0d88 | 38 | .PP |
022671eb | 39 | If |
d8a86e74 | 40 | .I x |
022671eb MK |
41 | is integral, infinite, or NaN, |
42 | .I x | |
43 | itself is returned. | |
fea681da | 44 | .SH ERRORS |
f1ab30a7 | 45 | No errors occur. |
f0d7ce1d MK |
46 | .SH VERSIONS |
47 | These functions first appeared in glibc in version 2.1. | |
d265b8f2 | 48 | .SH ATTRIBUTES |
7b389f3c PH |
49 | For an explanation of the terms used in this section, see |
50 | .BR attributes (7). | |
c466875e MK |
51 | .ad l |
52 | .nh | |
7b389f3c PH |
53 | .TS |
54 | allbox; | |
c466875e | 55 | lbx lb lb |
7b389f3c PH |
56 | l l l. |
57 | Interface Attribute Value | |
58 | T{ | |
d265b8f2 PH |
59 | .BR trunc (), |
60 | .BR truncf (), | |
d265b8f2 | 61 | .BR truncl () |
7b389f3c PH |
62 | T} Thread safety MT-Safe |
63 | .TE | |
c466875e MK |
64 | .hy |
65 | .ad | |
66 | .sp 1 | |
47297adb | 67 | .SH CONFORMING TO |
9a74e018 | 68 | C99, POSIX.1-2001, POSIX.1-2008. |
f1ab30a7 MK |
69 | .SH NOTES |
70 | The integral value returned by these functions may be too large | |
71 | to store in an integer type | |
72 | .RI ( int , | |
73 | .IR long , | |
74 | etc.). | |
75 | To avoid an overflow, which will produce undefined results, | |
76 | an application should perform a range check on the returned value | |
77 | before assigning it to an integer type. | |
47297adb | 78 | .SH SEE ALSO |
fea681da MK |
79 | .BR ceil (3), |
80 | .BR floor (3), | |
81 | .BR lrint (3), | |
82 | .BR nearbyint (3), | |
83 | .BR rint (3), | |
84 | .BR round (3) |