I have a PRNG-Algorithm:
/**
* Generates an integer. Min: 0 | Max: total - 1
* @param total The number of possibilities.
* @return The generated number.*/
public function generate_normal(total:int):int
{
_seed = (_seed * MULTIPLIER) % MODULUS;
return (_seed * total / MODULUS);
}
The constants are defined as follows:
/**The Multiplier.*/
private const MULTIPLIER:int = 48271;
/**The Modulus.*/
private const MODULUS:int = 2147483647;
This is readable and understandable, but pretty slow (~50% more time).
Simply using the numbers would be faster, but less readable. Will people call these numbers "magic" and kill me or will everything be fine? Should I change this part in the class description:
Modulus suggested 1988 by Stephen K. Park and Keith W. Miller.
Multiplier suggested 1993 by Park and Miller.
to this:
Modulus (2147483647) suggested 1988 by Stephen K. Park and Keith W. Miller.
Multiplier (48271) suggested 1993 by Park and Miller.
Should I keep my approach or use the numbers directly?
TL;DR What's more important, performance or readability?