Category : C++ Source Code
Archive   : VCCRT1.ZIP
Filename : RAND.C

 
Output of file : RAND.C contained in archive : VCCRT1.ZIP
/***
*rand.c - random number generator
*
* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
*
*Purpose:
* defines rand(), srand() - random number generator
*
*******************************************************************************/

#include

static long holdrand = 1L;

/***
*void srand(seed) - seed the random number generator
*
*Purpose:
* Seeds the random number generator with the int given. Adapted from the
* BASIC random number generator.
*
*Entry:
* unsigned seed - seed to seed rand # generator with
*
*Exit:
* None.
*
*Exceptions:
*
*******************************************************************************/

void srand (seed)
unsigned int seed;
{
holdrand = (long)seed;
}


/***
*int rand() - returns a random number
*
*Purpose:
* returns a pseudo-random number 0 through 32767.
*
*Entry:
* None.
*
*Exit:
* Returns a pseudo-random number 0 through 32767.
*
*Exceptions:
*
*******************************************************************************/

int rand ()
{
return(int)(((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);
}


  3 Responses to “Category : C++ Source Code
Archive   : VCCRT1.ZIP
Filename : RAND.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/