[ create a new paste ] login | about

Link: http://codepad.org/i9g3QqCQ    [ raw code | output | fork ]

Python, pasted on Aug 28:
1
2
3
4
5
6
7
8
import random

class R(random.Random):
    def random(self): # override random to suppress getrandbits usage
        return random.random()

r = R()
r.randrange(2**2000)


Output:
1
2
3
4
5
6
7
8
9
10
11
/usr/lib/python2.5/random.py:240: UserWarning: Underlying random() generator does not supply 
enough bits to choose from a population range this large
  _warn("Underlying random() generator does not supply \n"
Traceback (most recent call last):
  Line 8, in <module>
    r.randrange(2**2000)
  File "/usr/lib/python2.5/random.py", line 164, in randrange
    return self._randbelow(istart)
  File "/usr/lib/python2.5/random.py", line 242, in _randbelow
    return int(self.random() * n)
OverflowError: long int too large to convert to float


Create a new paste based on this one


Comments: