(s)
Convert a raw mpf to a rational number. Return integers (p, q)
    such that s = p/q exactly.
Convert a raw mpf to a rational number. Return integers (p, q)
    such that s = p/q exactly.
Convert a raw mpf to a rational number . Return integers ( p q ) such that s = p / q exactly .
def to_rational(s):
    """Convert a raw mpf to a rational number. Return integers (p, q)
    such that s = p/q exactly."""
    sign, man, exp, bc = s
    if sign:
        man = -man
    if bc == -1:
        raise ValueError("cannot convert %s to a rational number" % man)
    if exp >= 0:
        return man * (1<<exp), 1
    else:
        return man, 1<<(-exp)
def to_rational ( s ) : sign , man , exp , bc = s if sign : man = - man if bc == - 1 : raise ValueError ( "cannot convert %s to a rational number" % man ) if exp >= 0 : return man * ( 1 << exp ) , 1 else : return man , 1 << ( - exp )