I am trying to understand this code and I am not sure what language it is. It seems to be Java but I am not sure. I apologize if I am posting this incorrectly. I am volunteering and helping with a calendar and trying to find a random generator to work with basic. I am immediately trying to understand what this is doing.
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;
}
This seems to be a double LCG implemented in C# (I say C# instead of Java because IIRC Java doesn’t have
uint). You can find more about LCGs on Wikipedia.Still, most dialects of BASIC have some random number generator built in, typically using the instructions
RANDOMIZEfor initializing it andRANDorRANDOMto get a random number.