.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" .\" Modified 1993-03-29, David Metcalfe .\" Modified 1993-07-24, Rik Faith (faith@cs.unc.edu) .\" Modified 2002-08-10, 2003-11-01 Walter Harms, aeb .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1996 Kenji Kajiwara .\" all rights reserved. .\" Translated Mon Jul 15 18:00:00 JST 1996 .\" by Kenji Kajiwara .\" Proof Reading: Takashi Yoshino .\" Updated & Modified Sun May 30 13:03:43 JST 2004 .\" by Yuichi SATO .\" .TH DIV 3 2013\-07\-05 "" "Linux Programmer's Manual" .SH 名前 div, ldiv, lldiv, imaxdiv \- integer 型の割算の商と余りを計算する .SH 書式 .nf \fB#include \fP .sp \fBdiv_t div(int \fP\fInumerator\fP\fB, int \fP\fIdenominator\fP\fB);\fP .br \fBldiv_t ldiv(long \fP\fInumerator\fP\fB, long \fP\fIdenominator\fP\fB);\fP .br \fBlldiv_t lldiv(long long \fP\fInumerator\fP\fB, long long \fP\fIdenominator\fP\fB);\fP .sp \fB#include \fP .sp \fBimaxdiv_t imaxdiv(intmax_t \fP\fInumerator\fP\fB, intmax_t \fP\fIdenominator\fP\fB);\fP .fi .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .ad l .sp \fBlldiv\fP(): .RS 4 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L; .br or \fIcc\ \-std=c99\fP .RE .ad .SH 説明 \fBdiv\fP() 関数は \fInumerator\fP/\fIdenominator\fP の値を計算する。 商と余りは、 \fIquot\fP (商) と \fIrem\fP (余り) という名前の 2 つの integer 型メンバを含む \fIdiv_t\fP という構造体の中に返される (メンバの順番は不定である)。 商は 0 に近い方に丸められる。 結果は \fIquot\fP*\fIdenominator\fP+\fIrem\fP = \fInumerator\fP を満たす。 .LP \fBldiv\fP(), \fBlldiv\fP(), \fBimaxdiv\fP() 関数は同様な動作をし、 上に示した型の数値を割算して、上に示した名前の構造体に結果を返す。 どの場合でもフィールド \fIquot\fP と \fIrem\fP は、 関数の引き数と同じ型である。 .SH 返り値 \fIdiv_t\fP (などの) 構造体。 .SH 属性 .SS "マルチスレッディング (pthreads(7) 参照)" 関数 \fBdiv\fP(), \fBldiv\fP(), \fBlldiv\fP(), \fBimaxdiv\fP() はスレッドセーフである。 .SH 準拠 SVr4, 4.3BSD, C89, C99. 関数 \fBlldiv\fP() と \fBimaxdiv\fP() は C99 に追加された。 .SH 例 以下の式を計算すると、 .nf div_t q = div(\-5, 3); .fi \fIq.quot\fP と \fIq.rem\fP はそれぞれ \-1 と \-2 になる。 .SH 関連項目 \fBabs\fP(3), \fBremainder\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。