def mpf_norm(mpf, prec):
 (sign, man, expt, bc) = mpf
 if (not man):
  if (not bc):
   return _mpf_zero
  else:
   return mpf
 from mpmath.libmp.backend import MPZ
 rv = mpf_normalize(sign, MPZ(man), expt, bc, prec, rnd)
 return rv

def mpf_norm ( mpf , prec ) : ( sign , man , expt , bc ) = mpf if ( not man ) : if ( not bc ) : return _mpf_zero else : return mpf from mpmath . libmp . backend import MPZ rv = mpf_normalize ( sign , MPZ ( man ) , expt , bc , prec , rnd ) return rv
return the mpf tuple normalized appropriately for the indicated precision after doing a check to see if zero should be returned or not when the mantissa is 0 .