'Returns the exponent of the magnitude of self\'s MSD.
The result is the integer which is the exponent of the magnitude
of the most significant digit of self (as though it were truncated
to a single digit while maintaining the value of that digit and
without limiting the resulting exponent).'

def logb(self, context=None):

    ans = self._check_nans(context=context)
    if ans:
        return ans
    else:
        if (context is None):
            context = getcontext()
        if self._isinfinity():
            return _Infinity
        if (not self):
            return context._raise_error(DivisionByZero, 'logb(0)', 1)
        ans = Decimal(self.adjusted())
        return ans._fix(context)
