1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
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.
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.
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
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" References consulted:
24 .\" Linux libc source code
25 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
27 .\" Modified Sat Jul 24 19:46:03 1993 by Rik Faith (faith@cs.unc.edu)
29 .\" Japanese Version Copyright (c) 1997 YOSHINO Takashi
30 .\" all rights reserved.
31 .\" Translated Mon Jan 20 20:04:05 JST 1997
32 .\" by YOSHINO Takashi <yoshino@civil.jcn.nihon-u.ac.jp>
34 .\" WORD: internal buffer 内部バッファ
36 .TH DRAND48 3 2007-07-26 "" "Linux Programmer's Manual"
39 .\"O drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48,
40 .\"O lcong48 \- generate uniformly distributed pseudo-random numbers
41 drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48,
42 lcong48 \- 一様分布する疑似乱数を生成する関数
46 .B #include <stdlib.h>
48 .B double drand48(void);
50 .BI "double erand48(unsigned short " xsubi [3]);
52 .B long int lrand48(void);
54 .BI "long int nrand48(unsigned short " xsubi [3]);
56 .B long int mrand48(void);
58 .BI "long int jrand48(unsigned short " xsubi [3]);
60 .BI "void srand48(long int " seedval );
62 .BI "unsigned short *seed48(unsigned short " seed16v [3]);
64 .BI "void lcong48(unsigned short " param [7]);
68 .\"O Feature Test Macro Requirements for glibc (see
69 .\"O .BR feature_test_macros (7)):
71 .RB ( feature_test_macros (7)
76 .\"O All functions shown above:
87 _SVID_SOURCE || _XOPEN_SOURCE
91 .\"O These functions generate pseudo-random numbers using the linear congruential
92 .\"O algorithm and 48-bit integer arithmetic.
93 これらの関数は線形合同アルゴリズムと 48ビット整数演算を用いて
100 .\"O functions return nonnegative
101 .\"O double-precision floating-point values uniformly distributed between
108 一様分布する非負の倍精度浮動小数点実数値を返す。
114 .\"O functions return nonnegative
115 .\"O long integers uniformly distributed between 0 and 2^31.
127 .\"O functions return signed long
128 .\"O integers uniformly distributed between \-2^31 and 2^31.
134 \-2^31 と 2^31 の間で一様分布する符号付きロング整数を返す。
142 .\"O initialization functions, one of which should be called before using
153 .\"O an initialization function to be called first.
165 使用する前に、これらの初期化関数のいずれかを呼ぶべきである。
173 .\"O All the functions work by generating a sequence of 48-bit integers,
174 .\"O \fIXi\fP, according to the linear congruential formula:
175 ここで説明しているすべての関数は 48ビットの整数の
176 シーケンス (\fIXi\fP) を生成することで
177 機能している。生成方法は以下の線形合同の式による。
181 .B Xn+1 = (aXn + c) mod m,
185 .\"O The parameter \fIm\fP = 2^48, hence 48-bit integer arithmetic is performed.
188 .\"O is called, \fIa\fP and \fIc\fP are given by:
190 パラメータが \fIm\fP = 2^48 であるため、48ビット整数演算が行われている。
192 が呼ばれていない場合、\fIa\fP と \fIc\fP は以下の式で与えられる。
201 .\"O The value returned by any of the functions
210 .\"O computed by first generating the next 48-bit \fIXi\fP in the sequence.
211 .\"O Then the appropriate number of bits, according to the type of data item to
212 .\"O be returned, is copied from the high-order bits of \fIXi\fP and transformed
213 .\"O into the returned value.
222 はじめに、次の48ビットの \fIXi\fP が計算される。
223 そして、返すべきデータの型に依存した適切な
224 ビット数が \fIXi\fP の上位ビットからコピーされる。
233 .\"O the last 48-bit \fIXi\fP generated in an internal buffer.
239 .\"O require the calling
240 .\"O program to provide storage for the successive \fIXi\fP values in the array
241 .\"O argument \fIxsubi\fP.
242 .\"O The functions are initialized by placing the initial
243 .\"O value of \fIXi\fP into the array before calling the function for the first
250 最後に生成された48ビットの \fIXi\fP を内部バッファに格納する。
251 配列の形の引数 \fIxsubi\fP に個々の \fIXi\fP の値を
259 これらの関数は、はじめてそれらの関数を呼ぶ前に \fIXi\fP の初期値を配列に
262 .\"O The initializer function
264 .\"O sets the high order 32-bits of
265 .\"O \fIXi\fP to the argument \fIseedval\fP.
266 .\"O The low order 16-bits are set
267 .\"O to the arbitrary value 0x330E.
271 上位32ビットを引数 \fIseedval\fP に設定する。
272 下位の16ビットは、適当に決められた値である0x330Eに設定される。
274 .\"O The initializer function
276 .\"O sets the value of \fIXi\fP to
277 .\"O the 48-bit value specified in the array argument \fIseed16v\fP.
279 .\"O previous value of \fIXi\fP is copied into an internal buffer and a
280 .\"O pointer to this buffer is returned by
285 配列の形をした引数である \fIseed16v\fP の中で指定された 48ビットの値に設定する。
286 \fIXi\fP の前の値は内部バッファにコピーされ、このバッファへのポインタが
290 .\"O The initialization function
292 .\"O allows the user to specify
293 .\"O initial values for \fIXi\fP, \fIa\fP and \fIc\fP.
295 .\"O elements \fIparam[0-2]\fP specify \fIXi\fP, \fIparam[3-5]\fP specify
296 .\"O \fIa\fP, and \fIparam[6]\fP specifies \fIc\fP.
299 .\"O has been called, a subsequent call to either
303 .\"O will restore the standard values of \fIa\fP and \fIc\fP.
306 は使用者が \fIXi\fP, \fIa\fP, \fIc\fP の
308 配列の形をした引数の要素はそれぞれ、\fIparam[0-2]\fP は \fIXi\fP を、
309 \fIparam[3-5]\fP は \fIa\fP を、\fIparam[6]\fP は \fIc\fP を指定するもの
316 を呼ぶと、前述の \fIa\fP と \fIc\fP の
322 .\"O These functions are declared obsolete by SVID 3, which states that
324 .\"O should be used instead.
325 SVID 3 ではこれらの関数は時代遅れと宣言されている。
328 が代わりに使用されるべきだと記述されている。