def _randbelow(self, n, bpf=BPF, maxwidth=1L<<BPF,
                   long=long, _log=_log, int=int):
        """Return a random int in the range [0,n)

        Handles the case where n has more bits than returned
        by a single call to the underlying generator.
        """

        # k is a sometimes over but never under estimate of the bits in n
        k = int(1.00001 + _log(n/1, 2))     # 2**k > n-1 >= 2**(k-2)

        random = self.random
        r = n
        while r >= n:
            # In Py2.4, this section becomes:  r = self.getrandbits(k)
            r = long(random() * maxwidth)
            bits = bpf
            while bits < k:
                r = (r << bpf) | (long(random() * maxwidth))
                bits += bpf
            r >>= (bits - k)
        return r

## -------------------- sequence methods  -------------------
dataset/ETHPy150Open babble/babble/include/jython/Lib/random.py/Random._randbelow/operator `-` -> `/`