':type x: int
:rtype: int'

def reverse(self, x):

    if (x < 0):
        return (- self.reverse((- x)))
    result = 0
    while x:
        result = ((result * 10) + (x % 10))
        x /= 10
    return (result if (result <= 2147483647) else 0)
