📄 random.c
字号:
/************************************************************************/
/* C source file: ran_gen.c */
/* Author: Jean Gobert LEP (gobert@lep-philips.fr) */
/* Creation date: 14 Oct 1996 */
/* Last modified: */
/* abstract: this module generates random pixels. */
/* */
/* ran_gen [<low> [<high> [<number of blocks>]]] */
/* defauls : 0 255 10000 */
/* output on stdout */
/************************************************************************/
#include "tc.h"
/* random number generator specified in the appendix to */
/* Specification for p*64 kbit/s */
/* L and H must be longs, i.e., 32 bits */
long rand_dct( /* returned random number */
long L, /* low bound of range */
long H) /* high bound of range */
{
static double z = (double)0x7fffffff;
long i, j;
double x; /* double is 64 bits */
state->randx = (state->randx * 1103515245) + 12345;
i = state->randx & 0x7ffffffe; /* keep 30 bits */
x = ((double)i) / z; /* range 0 to 0.99999... */
x *= (L + H + 1); /* range 0 to < L + H + 1 */
j = x; /* truncate to integer */
return (j - L); /* range -L to H */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -