O_oI'll take yours as the new "best known method for an int within [0, RAND_MAX)"
Please don't explain either implementation in that way as the statement is entirely wrong.
The statement, especially highlighting of the ')' character, says that you don't appreciate the domain and range of the `nrand' function.
The `nrand' function aims to return an integer between [0, n)--including 0 and excluding `n'--where `n' is provided as an argument within a particular domain--the domain [2, RAND_MAX] for the original version. (Yes, you can pass 1 to the original `nrand', but the result is always 0 making it not a random value. The code has something of a bug; you should exclude the obvious "always the same value" from a "PRNG" by definition.) With respect to the range, the difference between the implementations is the domain: the version I posted has the domain [2, RAND_MAX - 1]. (Both implementations have the same range [0, n) for the same [2, RAND_MAX - 1] domain.) So, if you want to reference the valid range, "random int within" language, for the code I posted you would say "[0,n] as `n' within [2, RAND_MAX - 1)" or something similar.
One way or the other, the range [0, RAND_MAX) is specifically invalid with the code I posted.
Of course, you can increase the domain to [2, RAND_MAX) or even [2, RAND_MAX] if you desire, but the point of my implementation is the corrected bucket size which can be managed regardless of how one approaches a supported domain.
Soma