DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T r

⟦bd324eddf⟧ TextFile

    Length: 861 (0x35d)
    Types: TextFile
    Names: »random.c«

Derivation

└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen
    └─ ⟦this⟧ »cph85dist/stat/src/random.c« 

TextFile

/*LINTLIBRARY*/
#include "unixstat.h"
FUN(random,random number initialization,5.0,1985)

double	Maxrand;
#define	MAX32 2147483648.0
#define	MAX16 32768.0
#define MAXRAND (sizeof (int) == 4 ? MAX32 : MAX16)

#ifdef MSDOS /* manually seed random number generator */

/* get some random number to seed the random number generator */
getseed ()
	{
	char	answer[10];
	FILE	*ioptr;
	fputs ("Random seed: ", stderr);
	if (ioptr = fopen ("con:", "r"))
		{
		fgets (answer, 10, ioptr);
		fclose (ioptr);
		return (atoi (answer));
		}
	return (0);
	}

#endif

initrand ()
	{
	int 	seed;
#ifndef MSDOS /* no easy access to time and getpid on MSDOS */
	long 	clock;
	VOID time (&clock);
	seed = clock + getpid ();
#else
	if ((seed = getseed ()) == 0)
		fprintf (stderr, "\007random number generator not properly seeded\007\n");
#endif
	srand (seed);
	Maxrand = MAXRAND;
	}