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 - metrics - download
Index: T r

⟦28cb2a243⟧ TextFile

    Length: 872 (0x368)
    Types: TextFile
    Names: »random.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/General/Pm/BSD/random.c« 

TextFile

/*
** random.c -	yet another random number generator and random seed maker
**
**	[pm by Peter Costantinidis, Jr. @ University of California at Davis]
*/

#include "pm.h"

/*
** rnd()	- return a number between a and b, inclusive
*/
int	rnd (a, b)
reg	int	a, b;
{
	return((RN % (abs(b - a) + 1)) + a);
}

#ifndef	PATTERNS
/*
** get_seed()	- returns a seed for the random number generator
**		  dependent upon the time and date
*/
int	get_seed ()
{
	reg	int	seed;
	reg 	struct	tm	*timestruct;
	auto	long	clock;
	extern	long	time();
	extern	struct	tm	*localtime();

	clock = time(0);
	timestruct = localtime(&clock);
	seed = timestruct->tm_sec  +
	       timestruct->tm_min  +
	       timestruct->tm_hour +
	       timestruct->tm_mday +
	       timestruct->tm_mon  +
	       timestruct->tm_year +
	       timestruct->tm_yday;
	return((int) ((seed + clock) % 32767));
}
#endif