OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / original / man3 / rint.3
1 .\" Copyright 2001 Andries Brouwer <aeb@cwi.nl>.
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\"     <mtk.manpages@gmail.com>
4 .\"
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
25 .TH RINT 3  2008-08-05 "" "Linux Programmer's Manual"
26 .SH NAME
27 nearbyint, nearbyintf, nearbyintl, rint, rintf, rintl \- round
28 to nearest integer
29 .SH SYNOPSIS
30 .nf
31 .B #include <math.h>
32 .sp
33 .BI "double nearbyint(double " x );
34 .br
35 .BI "float nearbyintf(float " x );
36 .br
37 .BI "long double nearbyintl(long double " x );
38 .sp
39 .BI "double rint(double " x );
40 .br
41 .BI "float rintf(float " x );
42 .br
43 .BI "long double rintl(long double " x );
44 .fi
45 .sp
46 Link with \fI\-lm\fP.
47 .sp
48 .in -4n
49 Feature Test Macro Requirements for glibc (see
50 .BR feature_test_macros (7)):
51 .in
52 .sp
53 .ad l
54 .BR nearbyint (),
55 .BR nearbyintf (),
56 .BR nearbyintl ():
57 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE; or
58 .I cc\ -std=c99
59 .br
60 .BR rint ():
61 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _ISOC99_SOURCE; or
62 .I cc\ -std=c99
63 .br
64 .BR rintf (),
65 .BR rintl ():
66 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE; or
67 .I cc\ -std=c99
68 .ad b
69 .SH DESCRIPTION
70 The
71 .BR nearbyint ()
72 functions round their argument to an integer value in floating-point
73 format, using the current rounding direction (see
74 .BR fesetround (3))
75 and without raising the
76 .I inexact
77 exception.
78 .LP
79 The
80 .BR rint ()
81 functions do the same, but will raise the
82 .I inexact
83 exception
84 .RB ( FE_INEXACT ,
85 checkable via
86 .BR fetestexcept (3))
87 when the result differs in value from the argument.
88 .SH "RETURN VALUE"
89 These functions return the rounded integer value.
90
91 If \fIx\fP is integral, +0, \-0, NaN, or infinite,
92 \fIx\fP itself is returned.
93 .SH ERRORS
94 No errors occur.
95 POSIX.1-2001 documents a range error for overflows, but see NOTES.
96 .SH "CONFORMING TO"
97 C99, POSIX.1-2001.
98 .SH NOTES
99 SUSv2 and POSIX.1-2001 contain text about overflow (which might set
100 .I errno
101 to
102 .BR ERANGE ,
103 or raise an
104 .B FE_OVERFLOW
105 exception).
106 In practice, the result cannot overflow on any current machine,
107 so this error-handling stuff is just nonsense.
108 (More precisely, overflow can happen only when the maximum value
109 of the exponent is smaller than the number of mantissa bits.
110 For the IEEE-754 standard 32-bit and 64-bit floating-point numbers
111 the maximum value of the exponent is 128 (respectively, 1024),
112 and the number of mantissa bits is 24 (respectively, 53).)
113
114 If you want to store the rounded value in an integer type,
115 you probably want to use one of the functions described in
116 .BR lrint (3)
117 instead.
118 .SH "SEE ALSO"
119 .BR ceil (3),
120 .BR floor (3),
121 .BR lrint (3),
122 .BR round (3),
123 .BR trunc (3)