(self, p)
return int(self.digits[:p+1])
Given an integer p >= 0, return floor(10**p)*log(10).

        For example, self.getdigits(3) returns 2302.
Given an integer p >= 0, return floor(10**p)*log(10).
Given an integer p > = 0 return floor ( 10 ** p ) * log ( 10 ) .
def getdigits(self, p):
        """Given an integer p >= 0, return floor(10**p)*log(10).

        For example, self.getdigits(3) returns 2302.
        """
        # digits are stored as a string, for quick conversion to
        # integer in the case that we've already computed enough
        # digits; the stored digits should always be correct
        # (truncated, not rounded to nearest).
        if p < 0:
            raise ValueError("p should be nonnegative")

        if p >= len(self.digits):
            # compute p+3, p+6, p+9, ... digits; continue until at
            # least one of the extra digits is nonzero
            extra = 3
            while True:
                # compute p+extra digits, correct to within 1ulp
                M = 10**(p+extra+2)
                digits = str(_div_nearest(_ilog(10*M, M), 100))
                if digits[-extra:] != '0'*extra:
                    break
                extra += 3
            # keep all reliable digits so far; remove trailing zeros
            # and next nonzero digit
            self.digits = digits.rstrip('0')[:-1]
        return int(self.digits[:p+1])
def getdigits ( self , p ) : # digits are stored as a string, for quick conversion to # integer in the case that we've already computed enough # digits; the stored digits should always be correct # (truncated, not rounded to nearest). if p < 0 : raise ValueError ( "p should be nonnegative" ) if p >= len ( self . digits ) : # compute p+3, p+6, p+9, ... digits; continue until at # least one of the extra digits is nonzero extra = 3 while True : # compute p+extra digits, correct to within 1ulp M = 10 ** ( p + extra + 2 ) digits = str ( _div_nearest ( _ilog ( 10 * M , M ) , 100 ) ) if digits [ - extra : ] != '0' * extra : break extra += 3 # keep all reliable digits so far; remove trailing zeros # and next nonzero digit self . digits = digits . rstrip ( '0' ) [ : - 1 ] return int ( self . digits [ : p + 1 ] )