-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrnd.cpp
More file actions
52 lines (41 loc) · 1.18 KB
/
rnd.cpp
File metadata and controls
52 lines (41 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// rnd.cc
//*************************
// basic random number generator
// V 1.1
// 981111; 001028
//*************************
// (c) Markus Fiedler, ITM
// #include <values.h>
#define MAXLONG 2147483647
#include <time.h>//added
#include <stdlib.h>//added
#include <stdio.h>
#include <fstream>
#include <iostream>
#include "rnd.h"
using namespace std;
// initialization of static members ************************************
//double RND::SeedValue = 123457.0;
//srand(time(NULL));
int seed = rand() % time(NULL);
//ofstream myfile;
// myfile.open ("example.txt");
// myfile << "Writing this to a file.\n";
// myfile.close();
//FILE * pFile;
//pFile = fopen ("RANOMSEED.txt","w");
//fprintf(pFile,"Seed: %d\n",seed);
//fclose (pFile);
double RND::SeedValue = (double) seed;
double RND::RndValue = (double)RND::SeedValue / MAXLONG;
const double RND::Multiplic = 16807.0;
const double RND::MaxLongD = (double)MAXLONG;
const long RND::MaxLong = MAXLONG;
// Seed ****************************************************************
void RND::SetSeedValue(long value)
{
if ((value <= 0) || (value == MaxLong))
RndValue = 123457.0 / MaxLongD;
else
RndValue = value / MaxLongD;
}