RANDINT parameters

07152014, 12:22 AM
Post: #1




RANDINT parameters
What is the expected behavior of RANDINT? According to Help, RANDINT(r,a,b) returns a list of size r which each element being a random integer from a to b.
However, the returned list may include a if a is greater than or equal to 0, but it will not include a if a is less than 0. For example: RANDINT(5,1,1) returns {0,1,0,1,1} (but never a 1 in that list) RANDINT(5,2,1) returns {1,1,1,1,1} RANDINT(5,0,1} returns {1,0,1,1,1} Furthermore, while Help on RANDINT(r,a,b) seems to imply that a is less than b, the prime accepts inputs like RANDINT(r,5,5). I am not sure how to interpret the output. Any help? Thank you. 

07152014, 12:58 AM
Post: #2




RE: RANDINT parameters
The order of the 2nd and 3rd arguments doesn't matter:
RANDINT(a,b,c) is the same as RANDINT(a,c,b). Congratulations, you found a bug! If the lower limit is negative, it will never be returned; furthermore, if the upper limit is also negative, then the result will sometimes be one greater than the upper limit: RANDINT(5,2,3) > {2,2,1,2,1} RANDINT(5,4,4) > {3,3,3,3,3} <0ΙΈ0> Joe 

07152014, 01:06 AM
Post: #3




RE: RANDINT parameters  
« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)