```
class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
signed=1
if x!=abs(x):
signed=-1
num=abs(x)
outp = 0
while num!=0:
temp=num%10
outp=outp*10+temp
num=num/10
if outp > 2147483648 or x>2147483648:
return 0
return signed*outp
```