Please help me turn this random number generator into a function.
-
I have a random number generator:
private static uint GetUint() { m_z = 36969 * (m_z & 65535) + (m_z >> 16); m_w = 18000 * (m_w & 65535) + (m_w >> 16); return (m_z << 16) + m_w; } public static double GetUniform() { // 0 <= u < 2^32 uint u = GetUint(); // The magic number below is 1/(2^32 + 2). // The result is strictly between 0 and 1. return (u + 1.0) * 2.328306435454494e-10; }
It is said that I can set the two seeds with
SetSeed()
. The page that I found this on is: https://www.codeproject.com/Articles/25172/Simple-Random-Number-GenerationI am trying to turn this into a working function in which a new number shows up above every comment. The first seed is the last two digits of the comment_ID, and the second seed is the second of the_time, when the comment was posted.
The reason I am doing this is so that every comment has a new random number, but that number stays the same to the visitors from the moment the comment is posted, no matter who views the comment or whether they’ve refreshed the page or not.
I am not educated in PHP, but I will take any advice that is given and try to piece it together until my function works. So any help at all will be appreciated. Thank you.
- The topic ‘Please help me turn this random number generator into a function.’ is closed to new replies.