]>
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 | .\" | |
cc4615cc | 23 | .TH RINT 3 2007-07-26 "" "Linux Programmer's Manual" |
fea681da MK |
24 | .SH NAME |
25 | nearbyint, nearbyintf, nearbyintl, rint, rintf, rintl \- round to nearest integer | |
26 | .SH SYNOPSIS | |
27 | .nf | |
28 | .B #include <math.h> | |
29 | .sp | |
30 | .BI "double nearbyint(double " x ); | |
31 | .br | |
32 | .BI "float nearbyintf(float " x ); | |
33 | .br | |
34 | .BI "long double nearbyintl(long double " x ); | |
35 | .sp | |
36 | .BI "double rint(double " x ); | |
37 | .br | |
38 | .BI "float rintf(float " x ); | |
39 | .br | |
40 | .BI "long double rintl(long double " x ); | |
41 | .fi | |
42 | .sp | |
20c58d70 | 43 | Link with \fI\-lm\fP. |
cc4615cc MK |
44 | .sp |
45 | .in -4n | |
46 | Feature Test Macro Requirements for glibc (see | |
47 | .BR feature_test_macros (7)): | |
48 | .in | |
49 | .sp | |
50 | .ad l | |
51 | .BR nearbyint (), | |
52 | .BR nearbyintf (), | |
53 | .BR nearbyintl (): | |
54 | _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE; or | |
55 | .I cc\ -std=c99 | |
56 | .br | |
57 | .BR rint (), | |
58 | .BR rintf (), | |
59 | .BR rintl (): | |
60 | _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _ISOC99_SOURCE; or | |
61 | .I cc\ -std=c99 | |
62 | .ad b | |
fea681da MK |
63 | .SH DESCRIPTION |
64 | The | |
e511ffb6 | 65 | .BR nearbyint () |
fea681da MK |
66 | functions round their argument to an integer value in floating point |
67 | format, using the current rounding direction and without raising the | |
68 | .I inexact | |
69 | exception. | |
70 | .LP | |
71 | The | |
e511ffb6 | 72 | .BR rint () |
fea681da MK |
73 | functions do the same, but will raise the |
74 | .I inexact | |
75 | exception when the result differs in value from the argument. | |
76 | .SH "RETURN VALUE" | |
c13182ef MK |
77 | The rounded integer value. |
78 | If \fIx\fP is integral or infinite, | |
fea681da MK |
79 | \fIx\fP itself is returned. |
80 | .SH ERRORS | |
c8fe3fa2 MK |
81 | No errors other than |
82 | .B EDOM | |
83 | and | |
84 | .B ERANGE | |
85 | can occur. | |
fea681da MK |
86 | If \fIx\fP is NaN, then NaN is returned and |
87 | .I errno | |
2f0af33b MK |
88 | may be set to |
89 | .BR EDOM . | |
2b2581ee MK |
90 | .SH "CONFORMING TO" |
91 | C99. | |
fea681da | 92 | .SH NOTES |
68e1685c | 93 | SUSv2 and POSIX.1-2001 contain text about overflow (which might set |
fea681da | 94 | .I errno |
2f0af33b MK |
95 | to |
96 | .BR ERANGE , | |
97 | or raise an exception). | |
fea681da MK |
98 | In practice, the result cannot overflow on any current machine, |
99 | so this error-handling stuff is just nonsense. | |
100 | (More precisely, overflow can happen only when the maximum value | |
101 | of the exponent is smaller than the number of mantissa bits. | |
102 | For the IEEE-754 standard 32-bit and 64-bit floating point numbers | |
94d5cb11 MK |
103 | the maximum value of the exponent is 128 (respectively, 1024), and the number |
104 | of mantissa bits is 24 (respectively, 53).) | |
fea681da MK |
105 | .SH "SEE ALSO" |
106 | .BR ceil (3), | |
107 | .BR floor (3), | |
108 | .BR lrint (3), | |
fea681da MK |
109 | .BR round (3), |
110 | .BR trunc (3) |