]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 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 | .\" | |
23 | .TH ROUND 3 2001-05-31 "" "Linux Programmer's Manual" | |
24 | .SH NAME | |
25 | round, roundf, roundl \- round to nearest integer, away from zero | |
26 | .SH SYNOPSIS | |
27 | .nf | |
28 | .B #include <math.h> | |
29 | .sp | |
30 | .BI "double round(double " x ); | |
31 | .br | |
32 | .BI "float roundf(float " x ); | |
33 | .br | |
34 | .BI "long double roundl(long double " x ); | |
35 | .fi | |
36 | .sp | |
e9329f6d | 37 | Compile with \fI\-std=c99\fP; link with \fI\-lm\fP. |
fea681da MK |
38 | .SH DESCRIPTION |
39 | These functions round \fIx\fP to the nearest integer, but | |
40 | round halfway cases away from zero (regardless of the current rounding | |
c13182ef | 41 | direction), instead of to the nearest even integer like |
fb186734 | 42 | .BR rint (3). |
fea681da | 43 | .SH "RETURN VALUE" |
c13182ef MK |
44 | The rounded integer value. |
45 | If \fIx\fP is integral or infinite, | |
fea681da MK |
46 | \fIx\fP itself is returned. |
47 | .SH ERRORS | |
c8fe3fa2 MK |
48 | No errors other than |
49 | .B EDOM | |
50 | and | |
51 | .B ERANGE | |
52 | can occur. | |
fea681da MK |
53 | If \fIx\fP is NaN, then NaN is returned and |
54 | .I errno | |
2f0af33b MK |
55 | may be set to |
56 | .BR EDOM . | |
2b2581ee MK |
57 | .SH "CONFORMING TO" |
58 | C99. | |
fea681da | 59 | .SH NOTES |
68e1685c | 60 | POSIX.1-2001 contains text about overflow (which might set |
fea681da | 61 | .I errno |
2f0af33b MK |
62 | to |
63 | .BR ERANGE , | |
64 | or raise an exception). | |
fea681da MK |
65 | In practice, the result cannot overflow on any current machine, |
66 | so this error-handling stuff is just nonsense. | |
67 | (More precisely, overflow can happen only when the maximum value | |
68 | of the exponent is smaller than the number of mantissa bits. | |
69 | For the IEEE-754 standard 32-bit and 64-bit floating point numbers | |
70 | the maximum value of the exponent is 128 (resp. 1024), and the number | |
71 | of mantissa bits is 24 (resp. 53).) | |
fea681da MK |
72 | .SH "SEE ALSO" |
73 | .BR ceil (3), | |
74 | .BR floor (3), | |
75 | .BR lround (3), | |
76 | .BR nearbyint (3), | |
77 | .BR rint (3), | |
78 | .BR trunc (3) |