My Project
Loading...
Searching...
No Matches
Macros | Functions | Variables
sirandom.c File Reference
#include "misc/auxiliary.h"
#include "sirandom.h"

Go to the source code of this file.

Macros

#define A   16807 /* A "good" multiplier */
 
#define M   2147483647 /* Modulus: 2^31 - 1 */
 
#define Q   127773 /* M / A */
 
#define R   2836 /* M % A */
 

Functions

int siRandNext (int r)
 
int siRand ()
 
int siRandPlus1 (int r)
 

Variables

VAR int siSeed = 1
 

Macro Definition Documentation

◆ A

#define A   16807 /* A "good" multiplier */

Definition at line 24 of file sirandom.c.

◆ M

else L M   2147483647 /* Modulus: 2^31 - 1 */

Definition at line 25 of file sirandom.c.

◆ Q

#define Q   127773 /* M / A */

Definition at line 26 of file sirandom.c.

◆ R

#define R   2836 /* M % A */

Definition at line 27 of file sirandom.c.

Function Documentation

◆ siRand()

int siRand ( void  )

Definition at line 42 of file sirandom.c.

43{
45 return siSeed;
46}
int siRandNext(int r)
Definition: sirandom.c:32
VAR int siSeed
Definition: sirandom.c:30

◆ siRandNext()

int siRandNext ( int  r)

Definition at line 32 of file sirandom.c.

33{
34 r = A * (r % Q) - R * (r / Q);
35
36 if ( r < 0 )
37 r += M;
38
39 return( r );
40}
#define R
Definition: sirandom.c:27
#define A
Definition: sirandom.c:24
#define M
Definition: sirandom.c:25
#define Q
Definition: sirandom.c:26

◆ siRandPlus1()

int siRandPlus1 ( int  r)

Definition at line 47 of file sirandom.c.

48{
49 return r+1;
50}

Variable Documentation

◆ siSeed

VAR int siSeed = 1

Definition at line 30 of file sirandom.c.