Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SilentPanda

Moderator emeritus
Oct 8, 2002
9,992
31
The Bamboo Forest
I think that will give you random numbers from 2 to 6. You should change the 5 to a 4. The % 4 will give you numbers from 0-3 then the +2 will change that to 2-5. If I'm reading it correctly.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
FWIW...if you look at ScreenSaverView.h (spotlight it), Apple has some inline functions for generating random numbers (for copying into your source code). Kind of handy if you just need something quick.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.