dimanche 2 juin 2019

Generate Random Number from Bits

I have the following method which generates random bits:

private byte generateRandomBit()
{
    long randNum = (long) Math.Pow(Seed, 2) % M;
    Seed = randNum;
    if((Seed % 2) == 0)
    {
         return 0;
    }
    else
    {
         return 1;
    }
}

Now, I have another method that generates the next random number using the above method. I searched and found some answers, though they were not applicable to mine. Can anyone help me go around this please?




Aucun commentaire:

Enregistrer un commentaire