int ans = Integer.MAX_VALUE -(-1); //should I explicitly cast my method parameters in calculation to a wider bit type ?
Asked
Active
Viewed 31 times
1 Answers
0
Found a solution on searching the internet. An article that may help learners like me. https://www.drdobbs.com/jvm/signalling-integer-overflows-in-java/210500001

Ricko
- 5
- 1
- 5
-
another source with great solutions for the question https://wiki.sei.cmu.edu/confluence/display/java/NUM00-J.+Detect+or+prevent+integer+overflow – Ricko May 16 '21 at 07:36