RAND(3C)RAND(3C)NAME
rand, srand - random number generator
SYNOPSIS
srand(seed)
int seed;
rand()
DESCRIPTION
The newer random(3) should be used in new applications; rand remains for compatibilty.
Rand uses a multiplicative congruential random number generator with period 2**32 to return successive pseudo-random numbers in the range
from 0 to (2**31)-1 on the VAX, and (2**15)-1 on the PDP-11.
The generator is reinitialized by calling srand with 1 as argument. It can be set to a random starting point by calling srand with what-
ever you like as argument.
SEE ALSO random(3)7th Edition September 29, 1985 RAND(3C)
Check Out this Related Man Page
RAND(3) BSD Library Functions Manual RAND(3)NAME
rand, rand_r, srand, sranddev -- bad random number generator
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <stdlib.h>
int
rand(void);
int
rand_r(unsigned *seed);
void
srand(unsigned seed);
void
sranddev(void);
DESCRIPTION
These interfaces are obsoleted by arc4random(3).
The rand() function computes a sequence of pseudo-random integers in the range of 0 to RAND_MAX (as defined by the header file <stdlib.h>).
The srand() function sets its argument seed as the seed for a new sequence of pseudo-random numbers to be returned by rand(). These
sequences are repeatable by calling srand() with the same seed value.
If no seed value is provided, the functions are automatically seeded with a value of 1.
The sranddev() function initializes a seed, using the random(4) random number device which returns good random numbers. However, the rand()
function still remains unsuitable for cryptographic use.
The rand_r() function provides the same functionality as rand(). A pointer to the context value seed must be supplied by the caller.
SEE ALSO arc4random(3), random(3), random(4)STANDARDS
The rand() and srand() functions conform to ISO/IEC 9899:1990 (``ISO C90'').
The rand_r() function is as proposed in the POSIX.4a Draft #6 document.
BSD May 25, 1999 BSD
One way of getting epoch time in solaris is
truss date 2>&1 | awk '/^time/{print $3}'
Is there any other simple command that can be run from Korn Shell to display epoch time in solaris 5.10? (3 Replies)
Hi,
Do anybody knows how to use awk or any command to random print out 1000 number which start from range 1 to 150000?
I know that "rand" in awk can do similar random selection.
But I have no idea how to write a code that can random pick 1000 number from range 1 to 150000 :confused:
... (1 Reply)
Hi,
Is anybody experience generate a pair of random number by using awk command?
I wanna to generate a pair of random number (range from 1 to 4124) and repeats it 416 times.
Desired output
2 326
123 1256
341 14
3245 645
.
.
.
I did write the below command:
awk... (5 Replies)
Ok guys, gals and geeks...
As from today I am starting to learn awk in earnest doing something totally different.
I am going to create a pseudo-Audio_Function Generator centred around OSX 10.11.x minimum. The code below is a tester to see what the possibilities are.
All waveforms will be... (11 Replies)
I have a file contains thousands of lines. I want to insert n random numbers into each line at
specific position. Like this:
0 22……
1 33……
……
……
I want to insert 3 random numbers from position 2 to 4 into each line.
0 325 22……
1 685 33……
……
……
Please use CODE tags when... (8 Replies)
Hi Guys and gals...
As you know I am getting to grips with POSIX and hit this stumbling block.
Generating two random numbers 0 to 255 POSIXly. Speed in not important hence the 'sleep 1' command.
I have done a demo that works, but it sure is ugly! Is there a better way?
#!/bin/sh
# Random... (12 Replies)
Hi to everybody
again i Need your help, i wasting hours but can't find a solutuin for my Problem. I am not an expert with AIX script programming.
I have a csh script and i need the time in seconds but since i have an old AIX the Option -%s doesnot exist with the date command. I seach in Google... (13 Replies)
Hi there, friends!
Writing exams again! This time my wish would be to randomize certain columns in a csv file. Given a file containing records consisting of 3 columns tab-separated:
A B C
A B C
A B C
I would love to get the columns of each record in random order...separated by a tab as... (12 Replies)
Hey,
Just added a new UserCP option so you can change the code tags to look like the code tags in this example (turn this on and off):
Note: I set the default to "SyntaxHighlighting" for debugging purposes. We can change the default back to the original code tags later.
... (36 Replies)
Having trouble with the logic when looping over this switch case again:
for (j = 0; data != 0; j++){
switch(data){
case 'c':
output = ranit(r_brace_array);
break;
case 'h':
output = ranit(pipe_array);
break;
... (6 Replies)
current date command runs well
awk -v t="$(date +%Y-%m-%d)" -F "'" '$1 < t' myname.dat
subtract 30 days fails
awk -v t="$(date --date="-30days" +%Y-%m-%d)" -F "'" '$1 < t' myname.dat
awk command in hp unix subtract 30 days automatically from current date without date illegal option error... (20 Replies)