OSDN Git Service

d2fca95df4f488f50844cd0abfad7220cab88cdf
[linuxjm/LDP_man-pages.git] / release / man3 / div.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
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-03-29, David Metcalfe
31 .\" Modified 1993-07-24, Rik Faith (faith@cs.unc.edu)
32 .\" Modified 2002-08-10, 2003-11-01 Walter Harms, aeb
33 .\"
34 .\"*******************************************************************
35 .\"
36 .\" This file was generated with po4a. Translate the source file.
37 .\"
38 .\"*******************************************************************
39 .TH DIV 3 2013\-07\-05 "" "Linux Programmer's Manual"
40 .SH 名前
41 div, ldiv, lldiv, imaxdiv \- integer 型の割算の商と余りを計算する
42 .SH 書式
43 .nf
44 \fB#include <stdlib.h>\fP
45 .sp
46 \fBdiv_t div(int \fP\fInumerator\fP\fB, int \fP\fIdenominator\fP\fB);\fP
47 .br
48 \fBldiv_t ldiv(long \fP\fInumerator\fP\fB, long \fP\fIdenominator\fP\fB);\fP
49 .br
50 \fBlldiv_t lldiv(long long \fP\fInumerator\fP\fB, long long \fP\fIdenominator\fP\fB);\fP
51 .sp
52 \fB#include <inttypes.h>\fP
53 .sp
54 \fBimaxdiv_t imaxdiv(intmax_t \fP\fInumerator\fP\fB, intmax_t \fP\fIdenominator\fP\fB);\fP
55 .fi
56 .sp
57 .in -4n
58 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
59 .in
60 .ad l
61 .sp
62 \fBlldiv\fP():
63 .RS 4
64 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L;
65 .br
66 or \fIcc\ \-std=c99\fP
67 .RE
68 .ad
69 .SH 説明
70 \fBdiv\fP()  関数は \fInumerator\fP/\fIdenominator\fP の値を計算する。 商と余りは、 \fIquot\fP (商) と
71 \fIrem\fP (余り) という名前の 2 つの integer 型メンバを含む \fIdiv_t\fP という構造体の中に返される
72 (メンバの順番は不定である)。 商は 0 に近い方に丸められる。 結果は \fIquot\fP*\fIdenominator\fP+\fIrem\fP =
73 \fInumerator\fP を満たす。
74 .LP
75 \fBldiv\fP(), \fBlldiv\fP(), \fBimaxdiv\fP()  関数は同様な動作をし、
76 上に示した型の数値を割算して、上に示した名前の構造体に結果を返す。 どの場合でもフィールド \fIquot\fP と \fIrem\fP は、
77 関数の引き数と同じ型である。
78 .SH 返り値
79 \fIdiv_t\fP (などの) 構造体。
80 .SH 属性
81 .SS "マルチスレッディング (pthreads(7) 参照)"
82 The \fBdiv\fP(), \fBldiv\fP(), \fBlldiv\fP(), and \fBimaxdiv\fP()  functions are
83 thread\-safe.
84 .SH 準拠
85 SVr4, 4.3BSD, C89, C99.
86 関数 \fBlldiv\fP() と \fBimaxdiv\fP() は C99 に追加された。
87 .SH 例
88 以下の式を計算すると、
89 .nf
90
91         div_t q = div(\-5, 3);
92
93 .fi
94 \fIq.quot\fP と \fIq.rem\fP はそれぞれ \-1 と \-2 になる。
95 .SH 関連項目
96 \fBabs\fP(3), \fBremainder\fP(3)
97 .SH この文書について
98 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
99 である。プロジェクトの説明とバグ報告に関する情報は
100 http://www.kernel.org/doc/man\-pages/ に書かれている。