Perhaps you should do something like....

Example:
Code:
randnum = (rand() >> 16) & 7;