cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Random Numbers
Random Numbers
Nov 13, 2011 at 5:05pm UTC
InterFiction
(112)
(rand()&4)+1;
Why is that sometimes producing a 5? I thought that could only produce 1-4..
Nov 13, 2011 at 5:07pm UTC
shacktar
(1187)
It should be
(rand() % 4) + 1
. (Note the %)
Nov 13, 2011 at 5:08pm UTC
InterFiction
(112)
oops, I knew that too...Thanks.
Topic archived. No new replies allowed.