def _rshift_nearest(x, shift):
    """Given an integer x and a nonnegative integer shift, return closest
    integer to x / 2**shift; use round-to-even in case of a tie.

    """
    b, q = 1L << shift, x >> shift
    return q + (2*(x & (b-1)) + (q&1) > b)
dataset/ETHPy150Open deanhiller/databus/webapp/play1.3.x/python/Lib/decimal.py/_rshift_nearest/original