Random Integer Function - RandomInt(min, max, pm)
Description: Returns a random integer between min and max. If pm is set to -1, it will return a negative number. Inputs: Min, max, and pm (1 or -1) Outputs: A random integer between min and max, if pm is set to -1 the result will be negative.
//==========Rand Int========== // Input: min, max, pm // Output: random integer between min and max // pm denotes plus or minus function RandomInt(min, max, pm) { min = Math.ceil(min); max = Math.floor(max); pm = pm || 0; var plusMinus = Math.random() < 0.5 ? -1 : 1; var random = Math.floor(Math.random() * (max - min + 1)) + min; return pm != 0 ? random * plusMinus : random; }
Welcome to the University Wiki Service! Please use your IID (yourEID@eid.utexas.edu) when prompted for your email address during login or click here to enter your EID. If you are experiencing any issues loading content on pages, please try these steps to clear your browser cache.