random()?

random()?

Post by jgiff.. » Sat, 25 Apr 1992 05:20:28



this question is for the c programmers out there.  I have a few basic and pascal
programs that I would like to re-write in C, but a lot of them use some type of
random number generator.  I once saw a reference to a random() function, and I
am wondering if this (or some other random function)is included in gcc 2.1 .
If not, I have some C source to create a pseudo-random # based on a user inputed
seed.  I figure that if I use the date/time info for the seed, it should serve the
purpose.  However, I don't know the calls for time/date functions.  :(
(In case you can't tell, I am quite new to C, I am native to Pascal, but I have
a book written to teach C to Pascal programmers called: _C_Programming_in_a_UNIX
_Environment_  I got it for a class I didn't take.  I also have: _C_Primer_Plus_
by the Waite Group)

 
 
 

random()?

Post by Hongjiu Lu -- Graduate Stude » Sat, 25 Apr 1992 06:53:56



>this question is for the c programmers out there.  I have a few basic and pascal
>programs that I would like to re-write in C, but a lot of them use some type of
>random number generator.  I once saw a reference to a random() function, and I
>am wondering if this (or some other random function)is included in gcc 2.1 .
>If not, I have some C source to create a pseudo-random # based on a user inputed

As you may know, Linux is trying to be ANSI and POSIX compatible. All
the library functions are declared in the header files. Please take a
look at those files. Somebody is working on the list. I hope it will be
out soon.

I believe Linux has most of useful functions in library. Your random is
one of them. Take a look at your book and stdlib.h.

H.J.

 
 
 

1. Random Number generator not Random *****

Hi:

        I am using random()&01 to get a binary random
number. Turns out if I generate more than 50 numbers,
the last 30 or more are all 1s or 0s, i.e., my random
number generator is not random!

        Worse, if I generate 500 numbers, 497 are 1s.
The fraction of consistent numbers increases as the number
of trials increases.

        Any clues? Anybody got a pointer to an FAQ where
I can get a random number generator that is random?

Thanks in advance,

-Badri

2. Unix SCSI Driver

3. Trying to generate random random numbers!

4. Microsoft's word

5. Help, cgi-bin script "random" will only return last url in random list.

6. Recommended Embedded Linux distros

7. How random is random under Linux?

8. LAN + Cable modem help

9. Random Characters with RANDOM

10. ${RANDOM} not producing random numbers! (ksh, context switching?)

11. [RFC] Allow net devices to contribute to /dev/random

12. Random reboots, 3.1-R

13. random disconnections using select & nonblocking io