This is an easy question but i am stuck. Here is code for a Quasi Random Number Generator in this paper.
void PlaneHammersley(float *result, int n)
{
float p, u, v;
int k, kk, pos;
for (k=0, pos=0 ; k<n ; k++) {
u = 0;
for (p=0.5, kk=k ; kk ; p*=0.5, kk>>=1)
if (kk & 1) // kk mod 2 == 1
u += p;
v = (k + 0.5) / n;
result[pos++] = u;
result[pos++] = v;
}
}
i try to translate in Python and the second for loop is mysterious to me. The ending condition is kk which is an int and I dont know when it evaluates to True. Can someone explain what is happening?
Thanks.
Equivalent to: