Parcourir la source

Replace do-while with for-loop in GetRandomValue rejection sampling

pull/5392/head
Marcos De La Torre il y a 2 mois
Parent
révision
216785b5af
1 fichiers modifiés avec 3 ajouts et 2 suppressions
  1. +3
    -2
      src/rcore.c

+ 3
- 2
src/rcore.c Voir le fichier

@ -1758,11 +1758,12 @@ int GetRandomValue(int min, int max)
unsigned long t = c - (c % m); // largest multiple of m <= c
unsigned long r;
do
for (;;)
{
r = (unsigned long)rand();
if (r < t) break; // Only accept values within the fair region
}
while (r >= t);
value = min + (int)(r % m);
}

Chargement…
Annuler
Enregistrer