Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(1)  |  Call(0)  |  Derive(0)  |  Import(1)
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<
    


src/s/y/sympy-HEAD/sympy/polys/domains/mpelements.py   sympy(Download)
 
from sympy.mpmath.ctx_mp_python import PythonMPContext, _mpf, _mpc, _constant
from sympy.mpmath.libmp import (MPZ_ONE, fzero, fone, finf, fninf, fnan,
    round_nearest, mpf_mul, mpf_abs, mpf_lt, mpc_abs, repr_dps, int_types,
    from_int, from_float, from_str, to_rational)