OSDN Git Service

25729b7e6373263176898030a11b7e9aaca6399d
[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 2007-07-26 "" "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 .sp
64 .BR lldiv ():
65 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE; or
66 .I cc\ -std=c99
67 .SH ÀâÌÀ
68 .BR div ()
69 ´Ø¿ô¤Ï \fInumerator\fP/\fIdenominator\fP ¤ÎÃͤò·×»»¤¹¤ë¡£
70 ¾¦¤È;¤ê¤Ï¡¢
71 \fIquot\fP (¾¦) ¤È \fIrem\fP (;¤ê) ¤È¤¤¤¦Ì¾Á°¤Î 2 ¤Ä¤Î integer ·¿¥á¥ó¥Ð¤ò´Þ¤à
72 \fIdiv_t\fP ¤È¤¤¤¦¹½Â¤ÂΤÎÃæ¤ËÊÖ¤µ¤ì¤ë
73 (¥á¥ó¥Ð¤Î½çÈÖ¤ÏÉÔÄê¤Ç¤¢¤ë)¡£
74 ¾¦¤Ï 0 ¤Ë¶á¤¤Êý¤Ë´Ý¤á¤é¤ì¤ë¡£
75 ·ë²Ì¤Ï \fIquot\fP*\fIdenominator\fP+\fIrem\fP = \fInumerator\fP ¤òËþ¤¿¤¹¡£
76 .LP
77 .BR ldiv (),
78 .BR lldiv (),
79 .BR imaxdiv ()
80 ´Ø¿ô¤ÏƱÍͤÊÆ°ºî¤ò¤·¡¢
81 ¾å¤Ë¼¨¤·¤¿·¿¤Î¿ôÃͤò³ä»»¤·¤Æ¡¢¾å¤Ë¼¨¤·¤¿Ì¾Á°¤Î¹½Â¤ÂΤ˷ë²Ì¤òÊÖ¤¹¡£
82 ¤É¤Î¾ì¹ç¤Ç¤â¥Õ¥£¡¼¥ë¥É \fIquot\fP ¤È \fIrem\fP ¤Ï¡¢
83 ´Ø¿ô¤Î°ú¤­¿ô¤ÈƱ¤¸·¿¤Ç¤¢¤ë¡£
84 .SH ÊÖ¤êÃÍ
85 \fIdiv_t\fP (¤Ê¤É¤Î) ¹½Â¤ÂΡ£
86 .SH ½àµò
87 SVr4, 4.3BSD, C89.
88 ´Ø¿ô
89 .BR lldiv ()
90 ¤È
91 .BR imaxdiv ()
92 ¤Ï C99 ¤ËÄɲ䵤줿¡£
93 .SH Îã
94 .nf
95
96         div_t q = div(\-5, 3);
97
98 .fi
99 ¤ò·×»»¤¹¤ë¤È¡¢\fIq.quot\fP ¤È \fIq.rem\fP ¤Ï¤½¤ì¤¾¤ì \-1 ¤È \-2 ¤Ë¤Ê¤ë¡£
100 .SH ´ØÏ¢¹àÌÜ
101 .BR abs (3),
102 .BR remainder (3)