Ejemplo n.º 1
0
 def __new__(cls, num, prec=15):
     prec = mpmath.settings.dps_to_prec(prec)
     if isinstance(num, (int, long)):
         return Integer(num)
     if isinstance(num, (str, decimal.Decimal)):
         _mpf_ = mlib.from_str(str(num), prec, rnd)
     elif isinstance(num, tuple) and len(num) == 4:
         _mpf_ = num
     else:
         _mpf_ = mpmath.mpf(num)._mpf_
     if not num:
         return C.Zero()
     obj = Basic.__new__(cls)
     obj._mpf_ = _mpf_
     obj._prec = prec
     return obj