Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/waterbox/libc/functions/stdlib/rand.c
2 views
1
/* rand( void )
2
3
This file is part of the Public Domain C Library (PDCLib).
4
Permission is granted to use, modify, and / or redistribute at will.
5
*/
6
7
#include <stdlib.h>
8
9
#ifndef REGTEST
10
11
int rand( void )
12
{
13
_PDCLIB_seed = _PDCLIB_seed * 1103515245 + 12345;
14
return (int)( _PDCLIB_seed / 65536 ) % 32768;
15
}
16
17
#endif
18
19
#ifdef TEST
20
#include "_PDCLIB_test.h"
21
22
int main( void )
23
{
24
int rnd1, rnd2;
25
TESTCASE( ( rnd1 = rand() ) < RAND_MAX );
26
TESTCASE( ( rnd2 = rand() ) < RAND_MAX );
27
srand( 1 );
28
TESTCASE( rand() == rnd1 );
29
TESTCASE( rand() == rnd2 );
30
return TEST_RESULTS;
31
}
32
33
#endif
34
35