Skip to content

Conversation

@toffer
Copy link

@toffer toffer commented Mar 5, 2013

The randrange() method for RandomDotOrg works fine when called with both start and stop args. But, when randrange() is called with just a start arg (no stop), it returns a value outside of the range. (Way outside!)

$ python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import randomSources
>>> rng = randomSources.RandomDotOrg()
>>> rng.randrange(1, 7)
5
>>> rng.randrange(7)
-999999995

Looking through the other paths through the randrange method, I see that the response from randrange is usually "shifted" before returning the value.

When it's called with just a start arg, no shifting happens.

I've added what I believe to be the correct shift, but I'm not 100% confident I've got it right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant