# Question

Formatted question description: https://leetcode.ca/all/7.html

```
7 Reverse Integer
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
Example 3:
Input: 120
Output: 21
[click to show spoilers.]
Have you thought about this?
Here are some good questions to ask before coding. Bonus points for you if you have already thought through this!
If the integer's last digit is 0, what should the output be? ie, cases such as 10, 100.
Did you notice that the reversed integer might overflow? Assume the input is a 32-bit integer, then the reverse of 1000000003 overflows. How should you handle such cases?
For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.
Note:
The input is assumed to be a 32-bit signed integer. Your function should return 0 when the reversed integer overflows.
```

# Algorithm

One thing to pay attention to when flipping numbers is the overflow problem. After reading many online solutions, since the previous OJ did not test for overflow, many people’s solutions on the internet can pass OJ without dealing with the overflow problem.

Now OJ has updated the overflow test, so it still needs to be considered. Why is there an overflow problem? Since the value range of the int type is -2147483648～2147483647, if you want to flip the number within the range of 1000000009 to get 9000000001, the number after the flip exceeds the range. The initial idea of the blogger is to use long data, the value range of which is -9223372036854775808~9223372036854775807, which is much larger than int so that there will be no overflow problem.

# Code

Java