def _mag(x):
 from math import log10, ceil, log
 from sympy import Float
 xpos = abs(x.n())
 if (not xpos):
  return S.Zero
 try:
  mag_first_dig = int(ceil(log10(xpos)))
 except (ValueError, OverflowError):
  mag_first_dig = int(ceil((Float(mpf_log(xpos._mpf_, 53)) / log(10))))
 if ((xpos / (10 ** mag_first_dig)) >= 1):
  assert (1 <= (xpos / (10 ** mag_first_dig)) < 10)
  mag_first_dig += 1
 return mag_first_dig

def _mag ( x ) : from math import log10 , ceil , log from sympy import Float xpos = abs ( x . n ( ) ) if ( not xpos ) : return S . Zero try : mag_first_dig = int ( ceil ( log10 ( xpos ) ) ) except ( ValueError , OverflowError ) : mag_first_dig = int ( ceil ( ( Float ( mpf_log ( xpos . _mpf_ , 53 ) ) / log ( 10 ) ) ) ) if ( ( xpos / ( 10 ** mag_first_dig ) ) >= 1 ) : assert ( 1 <= ( xpos / ( 10 ** mag_first_dig ) ) < 10 ) mag_first_dig += 1 return mag_first_dig
return integer i such that .