OSDN Git Service

3189f11cb492fbc919b8131f0633a7e208330fc5
[linuxjm/LDP_man-pages.git] / release / man3 / remainder.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
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 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\"     386BSD man pages
29 .\"
30 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
31 .\" Modified 2002-08-10 Walter Harms
32 .\"     (walter.harms@informatik.uni-oldenburg.de)
33 .\" Modified 2003-11-18, 2004-10-05 aeb
34 .\"
35 .\" Japanese Version Copyright (c) 2004 Yuichi SATO
36 .\" and Copyright (c) 2008 Akihiro MOTOKI
37 .\" Translated 2004-09-02, Yuichi SATO <ysato444@yahoo.co.jp>
38 .\" Updated 2005-02-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
39 .\" Modified 2005-02-26, Yuichi SATO <ysato444@yahoo.co.jp>
40 .\" Updated 2008-09-16, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
41 .\"
42 .TH REMAINDER 3 2010-09-20 "" "Linux Programmer's Manual"
43 .SH 名前
44 drem, dremf, dreml, remainder, remainderf, remainderl \- 浮動小数点剰余関数
45 .SH 書式
46 .nf
47 .B #include <math.h>
48 .sp
49 /* C99 版 */
50 .BI "double remainder(double " x ", double " y );
51 .BI "float remainderf(float " x ", float " y );
52 .BI "long double remainderl(long double " x ", long double " y );
53 .sp
54 /* 廃止された別名 */
55 .BI "double drem(double " x ", double " y );
56 .BI "float dremf(float " x ", float " y );
57 .BI "long double dreml(long double " x ", long double " y );
58 .sp
59 .fi
60 \fI\-lm\fP でリンクする。
61 .sp
62 .in -4n
63 glibc 向けの機能検査マクロの要件
64 .RB ( feature_test_macros (7)
65 参照):
66 .in
67 .sp
68 .ad l
69 .BR remainder ():
70 .RS 4
71 _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
72 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED ||
73 _ISOC99_SOURCE ||
74 _POSIX_C_SOURCE\ >=\ 200112L;
75 .br
76 or
77 .I cc\ -std=c99
78 .RE
79 .br
80 .BR remainderf (),
81 .BR remainderl ():
82 .RS 4
83 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
84 _POSIX_C_SOURCE\ >=\ 200112L;
85 .br
86 or
87 .I cc\ -std=c99
88 .RE
89 .br
90 .BR drem (),
91 .BR dremf (),
92 .BR dreml ():
93 .RS 4
94 _SVID_SOURCE || _BSD_SOURCE
95 .RE
96 .ad b
97 .SH 説明
98 .BR remainder ()
99 関数は
100 .I x
101
102 .I y
103 で割った余りを計算する。
104 返り値は
105 \fIx\fP\-\fIn\fP*\fIy\fP
106 である。
107 ここで
108 .I n
109
110 .I "x\ /\ y"
111 の値を最も近い整数に丸めたものである。
112 \fIx\fP\-\fIn\fP*\fIy\fP
113 の絶対値が 0.5 の場合、偶数になるように
114 .I n
115 が選ばれる。
116
117 これらの関数は、現在の丸めモードの影響を受けない (丸めモードについては
118 .BR fenv (3)
119 を参照)。
120 .LP
121 .BR drem ()
122 関数はこれと全く同じ動作をする。
123 .SH 返り値
124 成功すると、これらの関数は浮動小数点の剰余 \fIx\fP\-\fIn\fP*\fIy\fP を返す。
125 返り値が 0 の場合、その符号は
126 .I x
127 と同じになる。
128
129 .I x
130
131 .I y
132 が NaN の場合、NaN が返される。
133
134 .I x
135 が無限大で
136 .I y
137 が NaN でない場合、
138 領域エラー (domain error) が発生し、NaN が返される。
139
140 .\" FIXME . Instead, glibc gives a domain error even if x is a NaN
141 .\" Interestingly, remquo(3) does not have the same problem.
142 .I y
143 がゼロで
144 .I x
145 が NaN でない場合、
146 領域エラーが発生し、NaN が返される。
147 .SH エラー
148 これらの関数を呼び出した際にエラーが発生したかの判定方法についての情報は
149 .BR math_error (7)
150 を参照のこと。
151 .PP
152 以下のエラーが発生する可能性がある。
153 .TP
154 領域エラー (domain error): \fIx\fP が無限大で \fIy\fP が NaN ではない
155 .\" .I errno
156 .\" is set to
157 .\" .BR EDOM .
158 不正 (invalid) 浮動小数点例外
159 .RB ( FE_INVALID )
160 が上がる。
161 .IP
162 これらの関数は、この場合に
163 .I errno
164 を設定しない。
165 .\" FIXME . Is it intentional that these functions do not set errno?
166 .\" They do set errno for the y == 0 case, below.
167 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6783
168 .TP
169 領域エラー: \fIy\fP がゼロで \fIx\fP が NaN ではない (下記の「バグ」参照)
170 .I errno
171
172 .B EDOM
173 が設定される。
174 不正 (invalid) 浮動小数点例外
175 .RB ( FE_INVALID )
176 が上がる。
177 .SH 準拠
178 .\" IEC 60559.
179 関数
180 .BR remainder (),
181 .BR remainderf (),
182 .BR remainderl ()
183 は C99 と POSIX.1-2001 で規定されている。
184
185 関数
186 .BR drem ()
187 は 4.3BSD に由来する。
188 .I float
189
190 .I "long double"
191 版の
192 .BR dremf ()
193
194 .BR dreml ()
195 は、Tru64 や glibc2 のようないくつかのシステムに存在する。
196 これらの関数の使用は避けて、
197 .BR remainder ()
198 などを使用すること。
199 .SH バグ
200
201     remainder(nan(""), 0);
202
203 の呼び出しを行うと、期待通り Nan が返るが、誤って領域エラーが発生する。
204 正しくはエラーなしの Nan となるべきである。
205 .\" FIXME . this bug occurs as at glibc 2.8.
206 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6779
207 .SH 例
208 "remainder(29.0, 3.0)" を呼び出すと \-1 を返す。
209 .SH 関連項目
210 .BR div (3),
211 .BR fmod (3),
212 .BR remquo (3)