OSDN Git Service

(split) Convert release and draft pages to UTF-8.
[linuxjm/LDP_man-pages.git] / release / man3 / div.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
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.
11 .\"
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.
19 .\"
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 .\" References consulted:
24 .\"     Linux libc source code
25 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\"     386BSD man pages
27 .\"
28 .\" Modified 1993-03-29, David Metcalfe
29 .\" Modified 1993-07-24, Rik Faith (faith@cs.unc.edu)
30 .\" Modified 2002-08-10, 2003-11-01 Walter Harms, aeb
31 .\"
32 .\" Japanese Version Copyright (c) 1996 Kenji Kajiwara
33 .\"         all rights reserved.
34 .\" Translated Mon Jul 15 18:00:00 JST 1996
35 .\"         by Kenji Kajiwara
36 .\" Proof Reading: Takashi Yoshino
37 .\" Updated & Modified Sun May 30 13:03:43 JST 2004
38 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
39 .\"
40 .TH DIV 3 2010-09-20 "" "Linux Programmer's Manual"
41 .SH 名前
42 div, ldiv, lldiv, imaxdiv \- integer 型の割算の商と余りを計算する
43 .SH 書式
44 .nf
45 .B #include <stdlib.h>
46 .sp
47 .BI "div_t div(int " numerator ", int " denominator );
48 .br
49 .BI "ldiv_t ldiv(long " numerator ", long " denominator );
50 .br
51 .BI "lldiv_t lldiv(long long " numerator ", long long " denominator );
52 .sp
53 .B #include <inttypes.h>
54 .sp
55 .BI "imaxdiv_t imaxdiv(intmax_t " numerator ", intmax_t " denominator );
56 .fi
57 .sp
58 .in -4n
59 glibc 向けの機能検査マクロの要件
60 .RB ( feature_test_macros (7)
61 参照):
62 .in
63 .ad l
64 .sp
65 .BR lldiv ():
66 .RS 4
67 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
68 _POSIX_C_SOURCE\ >=\ 200112L;
69 .br
70 or
71 .I cc\ -std=c99
72 .RE
73 .ad
74 .SH 説明
75 .BR div ()
76 関数は \fInumerator\fP/\fIdenominator\fP の値を計算する。
77 商と余りは、
78 \fIquot\fP (商) と \fIrem\fP (余り) という名前の 2 つの integer 型メンバを含む
79 \fIdiv_t\fP という構造体の中に返される
80 (メンバの順番は不定である)。
81 商は 0 に近い方に丸められる。
82 結果は \fIquot\fP*\fIdenominator\fP+\fIrem\fP = \fInumerator\fP を満たす。
83 .LP
84 .BR ldiv (),
85 .BR lldiv (),
86 .BR imaxdiv ()
87 関数は同様な動作をし、
88 上に示した型の数値を割算して、上に示した名前の構造体に結果を返す。
89 どの場合でもフィールド \fIquot\fP と \fIrem\fP は、
90 関数の引き数と同じ型である。
91 .SH 返り値
92 \fIdiv_t\fP (などの) 構造体。
93 .SH 準拠
94 SVr4, 4.3BSD, C89.
95 関数
96 .BR lldiv ()
97
98 .BR imaxdiv ()
99 は C99 に追加された。
100 .SH 例
101 .nf
102
103         div_t q = div(\-5, 3);
104
105 .fi
106 を計算すると、\fIq.quot\fP と \fIq.rem\fP はそれぞれ \-1 と \-2 になる。
107 .SH 関連項目
108 .BR abs (3),
109 .BR remainder (3)