Thread
:
tossing coin, logic problem ?
View Single Post
Jan 2nd, 2006, 4:37 AM
#
3
Polyphemus_
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power:
4
InfoGeek is right, and here is an optimization:
(
Toggle Plain Text
)
return rand() & 1;
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_
View Public Profile
Find More Posts by Polyphemus_