3 ms·
Maybe something more like: /* From Park and Miller (1988, pg 1195), using their notation */ const int A = 16807; const int M = 2147483647; const in
by mattkrause 7y ago
Maybe something more like:
/* From Park and Miller (1988, pg 1195), using their notation */
const int A = 16807;
const int M = 2147483647;
const int q = 127773;
const int r = 2836;
...
instead of "inlining" them into the code like
test = 16807 * (seed % 127773) - 2836 * (seed/127773)
The "ban" on literals obviously exempts their definition. No one, outside a number theory textbook, is defining A as successor(successor(...(successor(1)))
- morsch 7y ago> Park and Miller (1988, pg 1195) That's pretty cool. Did you at least have to look it up?
- mattkrause 7y agoI'm flattered you think there's even a tiny possibility I'd remember the constants or page :-) In reality, I vaguely remembered the authors and part of the title, then guess-and-googled the rest. It's a nice paper: https://dl.acm.org/doi/10.1145/63039.63042 https://dl.acm.org/doi/10.1145/63039.63042 though obviously no longer the state of the art. I recommend the citation-in-the comments idea though. We do it for lab stuff and it's very helpful for everything from debugging to writing up results.