View Single Post
Old Jan 2nd, 2006, 4:37 AM   #3
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
InfoGeek is right, and here is an optimization:
return rand() & 1;

This will do the same as % 2, but it is a lot faster. It masks out all the other bits, so all what remains is a 1 or a 0.
Polyphemus_ is offline   Reply With Quote