Author Topic: Help?  (Read 7725 times)

0 Members and 1 Guest are viewing this topic.

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Help?
« Reply #15 on: October 14, 2006, 10:25:59 pm »
So then shouldn't it be:

x = (rang()%20) + 5?

No!  If you devide something by 20, you can never have remander 20!  Think about what modulus means.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Help?
« Reply #16 on: October 15, 2006, 12:25:07 am »
So then shouldn't it be:

x = (rang()%20) + 5?

rang()? :P

Sorry, I think I missed a -1 in my formula.  Sorry :P

rand() % 20 returns a random number between 0 and 19, inclusive
+5 makes it 5 to 24.  The range is actually off by one.

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Help?
« Reply #17 on: October 15, 2006, 12:58:33 am »
So then shouldn't it be:

x = (rang()%20) + 5?

rang()? :P

Sorry, I think I missed a -1 in my formula.  Sorry :P

rand() % 20 returns a random number between 0 and 19, inclusive
+5 makes it 5 to 24.  The range is actually off by one.

You mean a + 1?  I see why saying -1 is valid too, but it's terribly misleading!