Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
07-16-2014, 09:39 PM #1
- Join Date
- Jul 2014
- Thanked 0 Times in 0 Posts
Knuth's subtractive random number generator. Which variables can be changed?
I have Knuth's subtractive random number generator code taken from this site: Subtractive generator - Rosetta Code
My question is:
What are the manipulating variables and what are the costants?
Are all the numbers in this code variables?
07-22-2014, 01:33 AM #2
Except for these variablesall named variables are just local variables. So the names don't matter to any code outside of each function; change them as you wish. All the numbers given in there are constants. Don't touch them. Could you instead declare them (esp. in C++ or C# or Java) as constants, assigning them names? Sure.Code:int state, si = 0, sj = 0;
int main()is just code to demonstrate how to use the two functions. You can throw it away and incorporate the other code in you C or C++ code (though it would be better to rewrite this a class in C++, of course).
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.