Ver a proveniência

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

pull/5392/head
Marcos De La Torre há 2 meses
ascendente
cometimento
216785b5af
1 ficheiros alterados com 3 adições e 2 eliminações
  1. +3
    -2
      src/rcore.c

+ 3
- 2
src/rcore.c Ver ficheiro

@ -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);
}

Carregando…
Cancelar
Guardar