Is this right? Seems like genrand(1) and genrand(2) will now do the same thing. Should we be calling ceilLog2(max+1) instead?
You're right Steve, it still fails on powers of two. I tested from 0 to 10 and it was correct with ceilLog2(max) + 1, so I'll go with that.
I'm happy to review an updated diff if you like.
It just turned into:
if (max == 0)
return 0;
int log = ceilLog2(max) + 1;
I tested it for max = 0 to max = 10 and it produced the appropriate results each time. The previous change would fail on powers of two.