(self)
return len(num) + e - (num < "231") - 1
Compute a lower bound for the adjusted exponent of self.log10().
        In other words, find r such that self.log10() >= 10**r.
        Assumes that self is finite and positive and that self != 1.
Compute a lower bound for the adjusted exponent of self.log10().
        In other words, find r such that self.log10() >= 10**r.
        Assumes that self is finite and positive and that self != 1.
Compute a lower bound for the adjusted exponent of self . log10 () . In other words find r such that self . log10 () > = 10 ** r . Assumes that self is finite and positive and that self ! = 1 .
def _log10_exp_bound(self):
        """Compute a lower bound for the adjusted exponent of self.log10().
        In other words, find r such that self.log10() >= 10**r.
        Assumes that self is finite and positive and that self != 1.
        """

        # For x >= 10 or x < 0.1 we only need a bound on the integer
        # part of log10(self), and this comes directly from the
        # exponent of x.  For 0.1 <= x <= 10 we use the inequalities
        # 1-1/x <= log(x) <= x-1. If x > 1 we have |log10(x)| >
        # (1-1/x)/2.31 > 0.  If x < 1 then |log10(x)| > (1-x)/2.31 > 0

        adj = self._exp + len(self._int) - 1
        if adj >= 1:
            # self >= 10
            return len(str(adj))-1
        if adj <= -2:
            # self < 0.1
            return len(str(-1-adj))-1
        op = _WorkRep(self)
        c, e = op.int, op.exp
        if adj == 0:
            # 1 < self < 10
            num = str(c-10**-e)
            den = str(231*c)
            return len(num) - len(den) - (num < den) + 2
        # adj == -1, 0.1 <= self < 1
        num = str(10**-e-c)
        return len(num) + e - (num < "231") - 1
def _log10_exp_bound ( self ) : # For x >= 10 or x < 0.1 we only need a bound on the integer # part of log10(self), and this comes directly from the # exponent of x.  For 0.1 <= x <= 10 we use the inequalities # 1-1/x <= log(x) <= x-1. If x > 1 we have |log10(x)| > # (1-1/x)/2.31 > 0.  If x < 1 then |log10(x)| > (1-x)/2.31 > 0 adj = self . _exp + len ( self . _int ) - 1 if adj >= 1 : # self >= 10 return len ( str ( adj ) ) - 1 if adj <= - 2 : # self < 0.1 return len ( str ( - 1 - adj ) ) - 1 op = _WorkRep ( self ) c , e = op . int , op . exp if adj == 0 : # 1 < self < 10 num = str ( c - 10 ** - e ) den = str ( 231 * c ) return len ( num ) - len ( den ) - ( num < den ) + 2 # adj == -1, 0.1 <= self < 1 num = str ( 10 ** - e - c ) return len ( num ) + e - ( num < "231" ) - 1