View Single Post
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-18-2017 , 09:07   Re: get_players() returning wrong value
Reply With Quote #29

Quote:
Originally Posted by PRoSToTeM@ View Post
random(X) is returning value from 0 to X-1, if X=0 then we should get value from 0 to -1, but there are no integer numbers between 0 and -1.
I understand the math. I'm talking about common sense usage of the function.

Quote:
Originally Posted by PRoSToTeM@ View Post
Also, you should never use random(0)%X instead of random_num(0, X-1), because with random(0)%X you won't get uniform distribution (rand in C/C++ has the same problem). And unfortunately random(X) also has this problem.
Yeah, I was thinking about that too.

Regardless, to maintain backward compatibility, the only thing that can be done is to document the behavior.
__________________
fysiks is offline