Skip to content

Commit a85ee7e

Browse files
committed
WMath.cpp
1 parent b06ce03 commit a85ee7e

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// WMath.cpp
2+
#include "Common.h"
3+
extern "C" {
4+
#include <stdlib.h>
5+
}
6+
7+
long random(long howbig) {
8+
if (howbig == 0) {
9+
return 0;
10+
}
11+
return (long)(rand() % howbig);
12+
}
13+
14+
long random(long howsmall, long howbig) {
15+
if (howsmall >= howbig) {
16+
return howsmall;
17+
}
18+
long diff = howbig - howsmall;
19+
return random(diff) + howsmall;
20+
}
21+
22+
void randomSeed(unsigned long seed) {
23+
if (seed != 0) {
24+
srand(seed);
25+
}
26+
}

0 commit comments

Comments
 (0)