Created
February 23, 2020 21:53
-
-
Save shuhei/2e0eb6d8f70c4b7c8dcb9c884d22d631 to your computer and use it in GitHub Desktop.
Java int overflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
System.out.println(Integer.MIN_VALUE); // -2147483648 | |
System.out.println(Integer.MAX_VALUE); // 2147483647 | |
System.out.println(Integer.MAX_VALUE + 1); // -2147483648 | |
System.out.println(-Integer.MIN_VALUE); // -2147483648 | |
System.out.println(-(Integer.MIN_VALUE + 1)); // 2147483647 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment