When you use arc4random , you avoid one mistake when using % with linear congruent generators (which is the usual algorithm used by rand ): the least significant bits are no less random.
However, you still have truncation problems: i.e. because (1 << 32) % 83 is 77, which means that numbers from 0 to 76 appear (slightly) more often than numbers between 77 and 82. To avoid this, you must throw away the input value (that is, call arc4random again) if it is higher (1 << 32) / 83 * 83 .
(I assume that arc4random range from 0 to 2 32 -1. Edit the explanation above accordingly.)
source share