'Converts self to an int, truncating if necessary.'

def __int__(self):

    if self._is_special:
        if self._isnan():
            context = getcontext()
            return context._raise_error(InvalidContext)
        elif self._isinfinity():
            raise OverflowError, 'Cannot    convert    infinity    to    long'
    if (self._exp >= 0):
        s = (''.join(map(str, self._int)) + ('0' * self._exp))
    else:
        s = ''.join(map(str, self._int))[:self._exp]
    if (s == ''):
        s = '0'
    sign = ('-' * self._sign)
    return int((sign + s))
