Unix and Linux Discussions Tagged with random |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
9 |
6,339 |
Shell Programming and Scripting |
|
|
|
11 |
2,729 |
Shell Programming and Scripting |
|
|
|
3 |
17,274 |
Shell Programming and Scripting |
|
|
|
6 |
4,873 |
Shell Programming and Scripting |
|
|
|
2 |
4,322 |
Programming |
|
|
|
2 |
10,832 |
Shell Programming and Scripting |
|
|
|
4 |
2,380 |
Windows & DOS: Issues & Discussions |
|
|
|
4 |
18,393 |
Shell Programming and Scripting |
|
|
|
0 |
1,253 |
Complex Event Processing RSS News |
|
|
|
2 |
6,282 |
Shell Programming and Scripting |
|
|
|
6 |
6,500 |
Shell Programming and Scripting |
|
|
|
1 |
7,465 |
Shell Programming and Scripting |
|
|
|
5 |
7,875 |
Shell Programming and Scripting |
|
|
|
2 |
15,926 |
Programming |
|
|
|
6 |
9,968 |
Programming |
|
|
|
8 |
9,986 |
Shell Programming and Scripting |
|
|
|
2 |
26,725 |
Programming |
|
|
|
2 |
2,702 |
Programming |
|
|
|
9 |
26,715 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,307 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
4,642 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,740 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
4,131 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
8,746 |
Cybersecurity |
rand(3C) rand(3C)
NAME
rand(), rand_r(), srand() - simple random-number generator
SYNOPSIS
DESCRIPTION
uses a multiplicative, congruential, random-number generator with period 2^32 that returns successive pseudo-random numbers in the range
from 0 to 2^15-1.
can be called at any time to reset the random-number generator to a random starting point. The generator is initially seeded with a value
of 1.
returns a random number at the address pointed to by the randval parameter. The seed parameter can be set at any time to start the random-
number generator at an arbitrary point.
Note
The spectral properties of leave a great deal to be desired. provides a much better, though more elaborate, random-number generator (see
drand48(3C)).
RETURN VALUE
If seed or randval is NULL, returns 0. Otherwise, returns a psuedo-random integer.
EXAMPLES
The following:
int x, y;
srand(10);
x = rand();
y = rand();
would produce the same results as:
int x, y, s = 10;
x=rand_r(&s);
y=rand_r(&s);
WARNINGS
Users of should note that rand_r() now conforms with POSIX.1c. The old prototype of is supported for compatibility with existing DCE
applications only.
SEE ALSO
drand48(3C), random(3M), thread_safety(5), random(7).
STANDARDS CONFORMANCE
rand(3C)