Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Dim GetRan As New Random
GetRan.Next(1, 50)

 

Why is it that this will never return the number 50? I thought the first number (in this case 1) is supposed to be the lowest possible number to return, and the second number (in this case 50) is supposed to be the highest possible number to return. But apparently, the highest number it can return is 1 - the second number (in this case 49).

To err is human, to really foul things up requires a computer.
Posted
It won't go up to 50 because it's basically saying, give me a random number from 1 up to 50. If you returned a double value on random, you'd get something like 1 to 49.99999999. Since you're using integer values, it's 1 to 49.
Gamer extraordinaire. Programmer wannabe.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...