Would you please explain what do you mean by unsatisfactory? I suppose most applications generate random numbers with these functions for cross-platform compatibility as they are standard.
In the rand() manpage, somewhere in the bottom, there is a note that discusses how to use that properly. Did you use it like that?
On some systems there are other means for random number generation. For instance, on Linux PCs the /dev/hwrandom represents a hardware random number generator . But this is only present if this support is compiled and available in the kernel. You may also try /dev/random and /dev/urandom.
Hi all,
I have a doubt in SQL Loader.
We have SEQUENCE function in SQL Loader or can create Sequence in Oracle database for generating a number sequence for
a column while loading data using SQL Loader into table or multiple tables.
My requirment is this.
For the first run in SQL... (2 Replies)
I need to generate a random number in ksh everytime I run the script ,the range should be from 100 to 24800,I could use $RANDOM but I seem to have no control over the range of numbers ,could you please suggest some way I could implement this .Thanks.
Mervin (2 Replies)
Hi Folks,
Can you help me with this issue:
I have to generate the numbers say from 1001 for each record in a file based on a key field,
the catch is the generated number should be unique based on key column.
(EMP_NUMBER)
Example:
Input File:
EMP_NUMBER EMP_NAME
8908 ... (6 Replies)
HI
please help me in solving this issue.
I have a shell script which consists of ten statemnts ( i mean 10 executable statments)...........and if i run that script the 10 statmenst will execute continously ............
But now my probelm is i have to write another script --> to... (0 Replies)
Hi
I have the below code
MAXCOUNT=10
count=1
echo
echo "$MAXCOUNT random numbers:"
echo "-----------------"
while # Generate 10 ($MAXCOUNT) random integers.
do
number=$ + 1 ]
"echo $number"
let "count += 1" # Increment count.
done
But aftre executing this
... (8 Replies)
i tried to use $random function in unix
i simply typed print $random at shell and it returnted no value
is there any function in korn shell that i can use to generate random number
help is appreciated (2 Replies)
I need to generate and reuse a 5 digit random number every time my program is executed. But the following generates random numbers every time the function is called.
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <time.h>
... (12 Replies)
Hi - I have a word GTTCAGAGTTCTACAGTCCGACGAT
I need to extract all the possible "chunks" of 7 or above letter "words" from this.
SO, my out put should be
GTTCAGA
TTCAGAG
TCAGAGT
CAGAGTTCT
TCCGACGAT
CAGTCCGACG
etc.
How can I do that with awk or any other language? I have no... (2 Replies)
Hello,
I have created a script to generate a random password on Linux/Solaris, but I simply cannot use it on my AIX VMs since Bash isn't installed on them.
I need a password that is randomly created with the following... (12 Replies)
Discussion started by: gfroute
12 Replies
LEARN ABOUT SUNOS
rand_r
rand(3C) Standard C Library Functions rand(3C)NAME
rand, srand, rand_r - simple random-number generator
SYNOPSIS
#include <stdlib.h>
int rand(void);
void srand(unsigned int seed);
int rand_r(unsigned int *seed);
DESCRIPTION
The rand() function uses a multiplicative congruential random-number generator with period 2**32 that returns successive pseudo-random num-
bers in the range of 0 to RAND_MAX (defined in <stdlib.h>).
The srand() function uses the argument seed as a seed for a new sequence of pseudo-random numbers to be returned by subsequent calls to
rand(). If srand() is then called with the same seed value, the sequence of pseudo-random numbers will be repeated. If rand() is called
before any calls to srand() have been made, the same sequence will be generated as when srand() is first called with a seed value of 1.
The rand_r() function has the same functionality as rand() except that a pointer to a seed seed must be supplied by the caller. If
rand_r() is called with the same initial value for the object pointed to by seed and that object is not modified between successive calls
to rand_r(), the same sequence as that produced by calls to rand() will be generated.
The rand() and srand() functions provide per-process pseudo-random streams shared by all threads. The same effect can be achieved if all
threads call rand_r() with a pointer to the same seed object. The rand_r() function allows a thread to generate a private pseudo-random
stream by having the seed object be private to the thread.
USAGE
The spectral properties of rand() are limited. The drand48(3C) function provides a better, more elaborate random-number generator.
When compiling multithreaded applications, the _REENTRANT flag must be defined on the compile line. This flag should be used only in mul-
tithreaded applications.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |Safe |
+-----------------------------+-----------------------------+
SEE ALSO drand48(3C), attributes(5), standards(5)SunOS 5.10 19 May 2004 rand(3C)